풀이

#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

typedef struct array array;
struct array{
	int time;
	int fee;
	int per;
	int j;
};
int comp(array a,array b)
{
	return a.per>b.per;
}

int main()
{
	int i,j,N,n,k;
	array arr[10000],tmp;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&N);
		for(j=0;j<N;j++){
			scanf("%d %d",&arr[j].time,&arr[j].fee);
		//	arr[j].per=arr[j].fee*arr[j].time;
			arr[j].j=j;
		}
		//sort(arr,arr+N,comp);
		for(j=0;j<N;j++){
			for(k=0;k<N-j;k++){
				if(arr[k].fee*arr[k+1].time<arr[k+1].fee*arr[k].time){
					tmp=arr[k];
					arr[k]=arr[k+1];
					arr[k+1]=tmp;
				}
			}
		}
		for(j=0;j<N;j++){
			printf("%d",arr[j].j+1);
			if(j!=N-1)printf(" ");
		}
		if(i!=n-1)printf("\n\n");
	}
    return 0;
}
  • 역시 원인을 알 수 없는 Wrong answer .... 뒤에 풀이까지 참고해봤지만 fail
Retrieved from http://wiki.zeropage.org/wiki.php/Shoemaker's_Problem/김태진
last modified 2021-02-07 05:28:01