nkoj 1887

//因为 “太听话” 将数组开成按照他说的,所以Running time error了好几次,最可气的是犯了一个低级错误,就是Presentation Error!!!

所以,我从这道水题上学会了小心两个字,还有就是不能太听话啊!!!

 

 

#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define max_n 202
#define max_m 12
int N, M;
typedef struct{
	string id;
	int info[max_m];
	int timee;
	int num;
}team;
team T[max_n];
int main()
{
	while (cin >> N >> M){
		for (int i = 0; i < N; i++){
			T[i].num = 0;
			T[i].timee = 0;
			cin >> T[i].id;
			for (int e = 0; e <2*M; e++){
				cin >> T[i].info[e];
			}
			for (int p = 0; p <M; p++){
				if (T[i].info[p] != -1){
					T[i].num++;
					T[i].timee += T[i].info[p];
				}
				else if(T[i].info[p]==-1){
					T[i].info[M+p] = 0;
				}
			}
			for (int p =M; p <2*M; p++){
				T[i].timee += 20 * T[i].info[p];
			}
		}
		for (int t = 0; t < N-1; t++){
			for (int f = t + 1; f < N; f++){
				if (T[t].num <T[f].num){
					team temp = T[t];
					T[t] = T[f];
					T[f] = temp;
				}
				if (T[t].num == T[f].num){
					if (T[t].timee>T[f].timee){
						team temp = T[t];
						T[t] = T[f];
						T[f] = temp;
					}
				}
			}
		}
		for (int o = 0; o < 3; o++){
			if (T[o].id.size() != 4){
				for (int l = T[o].id.size(); l < 4; l++){
					T[o].id = '0' + T[o].id;
				}
			}
			cout << T[o].id << " " << T[o].num << " " << T[o].timee << endl;
		}
		cout << endl;
	}
	return 0;
}


 

你可能感兴趣的:(算法,博客,计算机,ACM,nkoj)