-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA1075.cpp
78 lines (78 loc) · 1.51 KB
/
A1075.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
struct candidate
{
int id;
int s[5] = { -2,-2,-2,-2,-2 };
//int rank;
int num_pft = 0;
int sum = 0;
int flag = 0;
}list[10000];
bool cmp(candidate a, candidate b)
{
if (a.flag != b.flag)
return a.flag > b.flag;
else if (a.sum != b.sum)
return a.sum > b.sum;
else if (a.num_pft != b.num_pft)
return a.num_pft > b.num_pft;
else
return a.id < b.id;
}
int main()
{
int n, k, m;
scanf("%d%d%d", &n, &k, &m);
int* p = new int[k];
for (int i = 0; i < k; i++)
scanf("%d", p + i);
for (int i = 0; i < m; i++)
{
int id;
int p_n, score;
scanf("%d %d %d", &id, &p_n, &score);
//先是哪个id就放在哪个下表减1下面,然后分数按照之前一样的去判定
list[id - 1].id = id;
if (score > list[id - 1].s[p_n - 1])
{
list[id - 1].s[p_n - 1] = score;
if (score == p[p_n - 1])
list[id - 1].num_pft++;
if (score >= 0)
list[id - 1].flag = 1;
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < k; j++)
{
if (list[i].s[j] >= 0)
list[i].sum += list[i].s[j];
}
}
sort(list, list + n, cmp);
int r = 1;
for (int i = 0; i < n; i++)
{
if (!list[i].flag)
break;
if (i > 0 && list[i].sum != list[i - 1].sum)
r = i + 1;
printf("%d %05d %d", r, list[i].id, list[i].sum);
for (int j = 0; j < k; j++)
{
if (list[i].s[j] >= 0)
printf(" %d", list[i].s[j]);
else if (list[i].s[j] == -2)
printf(" -");
else
printf(" 0");
}
printf("\n");
}
return 0;
}