HDU1084
细节题
1,注意输出
2,当a[i].sum有偶数个时,前一半比后一半多5
3,当只有一个时,除100,50以外,输出90,80,70,60等等之类的
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<iostream> 5 #include<algorithm> 6 #include<queue> 7 #include<map> 8 #include<math.h> 9 using namespace std; 10 const int maxn = 105; 11 const int inf = 0x7fffffff; 12 struct node{ 13 int sum,time,id,ans; 14 }a[ maxn ]; 15 bool cmp(node a,node b){ 16 if( a.sum!=b.sum )return a.sum>b.sum; 17 else return a.time<b.time; 18 } 19 bool cmp2(node a,node b){ 20 return a.id<b.id; 21 } 22 int main(){ 23 int n; 24 int n1,n2,n3,n4,n5; 25 while( scanf("%d",&n)!=EOF ){ 26 if( n<=0 ) break; 27 char s[ 18 ]; 28 n1=n2=n3=n4=n5=0; 29 for( int i=1;i<=n;i++ ){ 30 scanf("%d %s",&a[ i ].sum,s); 31 a[ i ].id=i; 32 if( a[i].sum==1 ) n1++; 33 if( a[i].sum==2 ) n2++; 34 if( a[i].sum==3 ) n3++; 35 if( a[i].sum==4 ) n4++; 36 if( a[i].sum==5 ) n5++; 37 int res=0; 38 res=( (s[0]-'0')*10+(s[1]-'0') )*3600+( (s[3]-'0')*10+(s[4]-'0') )*60+( (s[6]-'0')*10+(s[7]-'0')); 39 a[i].time=res; 40 } 41 //for( int i=1;i<=n;i++ ){ 42 // printf("id:%d time:%d sum:%d\n",a[i].id,a[i].time,a[i].sum); 43 //} 44 // printf("\n"); 45 sort( a+1,a+n+1,cmp ); 46 //for( int i=1;i<=n;i++ ){ 47 // printf("id:%d time:%d sum:%d\n",a[i].id,a[i].time,a[i].sum); 48 //} 49 // printf("\n"); 50 int f4=1,f3=1,f2=1,f1=1; 51 //f1=f2=f3=f4=0; 52 /* 53 if(n1==1)n1++; 54 if(n2==1)n2++; 55 if(n3==1)n3++; 56 if(n4==1)n4++; 57 */ 58 for( int i=1;i<=n;i++ ){ 59 if( a[i].sum==5 ){ 60 a[i].ans=100;//printf("100\n"); 61 continue; 62 } 63 64 if( a[i].sum==0 ){ 65 a[i].ans=50;//printf("50\n"); 66 continue; 67 } 68 69 if( a[i].sum==4 && f4<=(n4/2) ){ 70 f4++; 71 a[i].ans=95;//printf("95\n"); 72 continue; 73 } 74 else if( a[i].sum==4 ){ 75 f4++; 76 a[i].ans=90;//printf("90\n"); 77 continue; 78 } 79 80 if( a[i].sum==3 && f3<=(n3/2) ){ 81 f3++; 82 a[i].ans=85;//printf("85\n"); 83 continue; 84 } 85 else if( a[i].sum==3 ){ 86 f3++; 87 a[i].ans=80;//printf("80\n"); 88 continue; 89 } 90 91 if( a[i].sum==2 && f2<=(n2/2) ){ 92 f2++; 93 a[i].ans=75;//printf("75\n"); 94 continue; 95 } 96 else if( a[i].sum==2 ){ 97 f2++; 98 a[i].ans=70;//printf("70\n"); 99 continue; 100 } 101 102 if( a[i].sum==1 && f1<=(n1/2) ){ 103 f1++; 104 a[i].ans=65;//printf("65\n"); 105 continue; 106 } 107 else if( a[i].sum==1 ){ 108 f1++; 109 a[i].ans=60;//printf("60\n"); 110 continue; 111 } 112 113 } 114 sort( a+1,a+1+n,cmp2 ); 115 for( int i=1;i<=n;i++ ){ 116 // printf("id:%d time:%d ",a[i].id,a[i].time); 117 printf("%d\n",a[i].ans); 118 } 119 printf("\n"); 120 } 121 return 0; 122 }
keep moving...