-
Notifications
You must be signed in to change notification settings - Fork 0
/
uri 1586.c
61 lines (47 loc) · 1.1 KB
/
uri 1586.c
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
#include <cstdio>
#include <cstring>
#define SC1(a) scanf("%d", &a)
#define FOR(i, n) for(int i = 1; i <= (n); ++i)
using namespace std;
typedef long long LL;
int pon[100015];
char nom[100015][15];
int main(int argc, char const *argv[])
{
int n, r, sz;
LL tmpA, tmpB, tB, tA;
while(SC1(n) && n)
{
tmpB = tB = 0;
FOR(i, n)
{
pon[i] = 0;
scanf("%s", nom[i]);
sz = strlen(nom[i]);
for(int j = 0; j < sz; j++)
pon[i] += nom[i][j];
tmpB += pon[i];
tB += pon[i] * i;
}
r = tA = tmpA = 0;
FOR(i, n)
{
tB -= tmpB;
tmpB -= pon[i];
tmpA += pon[i];
tA += tmpA;
if(tA == tB)
{
r = i;
break;
}
if(tA > tB)
break;
}
if(r == 0)
puts("Impossibilidade de empate.");
else
printf("%s\n", nom[r]);
}
return 0;
}