-
Notifications
You must be signed in to change notification settings - Fork 0
/
marathon-winner.cpp
60 lines (51 loc) · 1.14 KB
/
marathon-winner.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
#include<bits/stdc++.h>
using namespace std;
void calcLead(int *lead, int *count, int n) {
int max = lead[0];
for(int i=0; i<n ; i++) {
if(max < lead[i]) {
max = lead[i];
}
}
for(int i=0; i<n; i++) {
if(lead[i] == max) {
count[i]++;
}
}
}
int main() {
int n, T;
cin >> n >> T;
int players[n][T];
int lead[n], count[n], distance[n];
memset(lead, 0, sizeof lead);
memset(count, 0, sizeof lead);
for(int i=0; i<n; i++) {
for(int j=0; j<T; j++) {
cin >> players[i][j];
}
cin >> distance[i];
}
if(T%2 != 0) {
T--;
}
for(int i=0; i<T; i=i+2) {
for(int j=0; j<n; j++) {
lead[j] += (players[j][i]+players[j][i+1])*distance[j];
}
calcLead(lead, count, n);
}
int maxLeadCount = count[0];
for(int i=0; i<n; i++) {
if(count[i] >= maxLeadCount) {
maxLeadCount = count[i];
}
}
for(int i=0; i<n; i++) {
if(count[i] == maxLeadCount) {
cout << i+1;
break;
}
}
return 0;
}