Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
不用排序的做法#include <stdio.h> int Solve(int n) { int i1=0; int list[10001]; int temp_distance=0; int temp_cost=0; int sum_candidate=0; int min_cost=20000; for(i1=0;i1<10001;i1++) list[i1]=20000; for(i1=0;i1<n;i1++) { scanf("%d %d",&temp_distance,&temp_cost); if(list[temp_distance]>temp_cost) list[temp_distance]=temp_cost; } for(i1=0;i1<10001;i1++) { if(list[i1]<=10000 && list[i1]<min_cost) { min_cost=list[i1]; sum_candidate++; } } return sum_candidate; } int main() { int N=0; do { scanf("%d",&N); if(N>0) printf("%d\n",Solve(N)); }while(N>0); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator