2013
12-12

# 九度-1007-奥运排序问题[解题代码]

4 4
4 8 1
6 6 2
4 8 2
2 12 4
0 1 2 3
4 2
8 10 1
8 11 2
8 12 3
8 13 4
0 3

1:3
1:1
2:1
1:2

1:1
1:1



cpp 代码如下：
#include <stdio.h>
#include <stdlib.h>
int * gold, * total, * people;
int n, m; int * conIndexs;
int main() {
while (scanf("%d %d", &n, &m) != EOF) {
gold = (int *) malloc(n * 4);
total = (int *) malloc(n * 4);
people = (int *) malloc(n * 4);
conIndexs = (int *) malloc(m * 4);
int i;
for (i = 0; i < n; i++)  scanf("%d %d %d", &gold[i], &total[i], &people[i]);
for (i = 0; i < m; i++) scanf("%d", &conIndexs[i]);
for (i = 0; i < m; i++) {
int lasttype = 1;int lastcnt = n;int type;
for (type = 1; type <= 4; type++) {
int cnt = 1;int j;
for (j = 0; j < m; j++) {
if (i != j) {
if (type == 1) {
if (gold[conIndexs[i]] < gold[conIndexs[j]])
cnt++;
} else if (type == 2) {
if (total[conIndexs[i]] < total[conIndexs[j]])
cnt++;
} else if (type == 3) {
if (gold[conIndexs[i]] * people[conIndexs[j]]
< gold[conIndexs[j]] * people[conIndexs[i]])
cnt++;
} else {
if (total[conIndexs[i]] * people[conIndexs[j]]
< total[conIndexs[j]]
* people[conIndexs[i]])
cnt++;
}
}
}
if (lastcnt > cnt) {
lastcnt = cnt;
lasttype = type;
}
}
printf("%d:%d\n", lastcnt, lasttype);
}
printf("\n");
}
return 0;
}

/**************************************************************
Problem: 1007
User: coder
Language: C
Result: Accepted
Time:0 ms
Memory:912 kb
****************************************************************/