Description
Input
Output
Sample Input
4 5 06:30:17 4 07:31:27 4 08:12:12 4 05:23:13 1 5 06:30:17 -1
Sample Output
100 90 90 95 100
#include <iostream> using namespace std; int main () { int n,i,j; char b[110]; while(cin >> n) { long long a[110]={0},c[110]={0},e[110]={0}; int q[5]={0}; if(n==-1) { break; } for(i=0;i<n;++i) { cin >> c[i]; if(c[i]==4) { q[4]++; } if(c[i]==3) { q[3]++; } if(c[i]==2) { q[2]++; } if(c[i]==1) { q[1]++; } cin >> b; for(j=0;b[j]!='\0';++j) { if(b[j]!=':') { a[i]+=b[j]-'0'; } a[i]*=10; } } q[4]/=2; q[3]/=2; q[2]/=2; q[1]/=2; for(i=0;i<n;++i) { for(j=0;j<n;++j) { if(c[i]==4) { if(a[i]>a[j]&&c[j]==4) { e[i]++; } } else if(c[i]==3) { if(a[i]>a[j]&&c[j]==3) { e[i]++; } } else if(c[i]==2) { if(a[i]>a[j]&&c[j]==2) { e[i]++; } } else if(c[i]==1) { if(a[i]>a[j]&&c[j]==1) { e[i]++; } } } } /* for(i=0;i<n;i++) { cout << e[i]+1 << endl; }*/ for(i=0;i<n;i++) { if(c[i]==5) { cout << 100 << endl; } else if(c[i]==0) { cout << 50 << endl; } else if(c[i]==4) { if(e[i]+1>q[4]) { cout << 90 << endl; } else { cout << 95 << endl; } } else if(c[i]==3) { if(e[i]+1>q[3]) { cout << 80 << endl; } else { cout << 85 << endl; } } else if(c[i]==2) { if(e[i]+1>q[2]) { cout << 70 << endl; } else { cout << 75 << endl; } } else if(c[i]==1) { if(e[i]+1>q[1]) { cout << 60 << endl; } else { cout << 65 << endl; } } } cout << endl; } return 0; }
原文地址:http://blog.csdn.net/zsc2014030403015/article/details/43484575