U E D R , A S I H C RSS

Shoemaker's_Problem/김태진

풀이

#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
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2012-08-20 20:13:25
Processing time 0.0063 sec