# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
159850 | 2019-10-25T03:51:39 Z | geon040702 | 컬러볼 (KOI15_ball) | C++14 | 130 ms | 8440 KB |
#include <stdio.h> #include <stdlib.h> #include <algorithm> using namespace std; #define N 200010 int n, s[N], total; int size[N], color[N], cnt; struct A { int size, color, index; int sum; } ; A a[N]; bool comp(A x, A y) { return x.size < y.size; } bool comp2(A x, A y) { return x.index < y.index; } int main() { int i, j; scanf("%d", &n); for(i=1;i<=n;i++) { scanf("%d %d", &a[i].color, &a[i].size); a[i].index = i; } sort(a+1, a+n+1, comp); for(i=1;i<=n;i++) { if(a[i].size != a[i-1].size) { for(j=1;j<=cnt;j++) { s[color[j]] += size[j]; total += size[j]; } cnt = 0; } cnt++; size[cnt] = a[i].size; color[cnt] = a[i].color; a[i].sum = total - s[a[i].color]; } sort(a + 1, a + n + 1, comp2); for(i=1;i<=n;i++) { printf("%d\n", a[i].sum); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 120 ms | 8440 KB | Output is correct |
2 | Correct | 118 ms | 8184 KB | Output is correct |
3 | Correct | 119 ms | 8184 KB | Output is correct |
4 | Correct | 119 ms | 8284 KB | Output is correct |
5 | Correct | 130 ms | 8112 KB | Output is correct |
6 | Correct | 4 ms | 504 KB | Output is correct |
7 | Correct | 5 ms | 592 KB | Output is correct |
8 | Correct | 4 ms | 504 KB | Output is correct |
9 | Correct | 4 ms | 504 KB | Output is correct |
10 | Correct | 5 ms | 504 KB | Output is correct |
11 | Correct | 110 ms | 6748 KB | Output is correct |
12 | Correct | 110 ms | 6648 KB | Output is correct |
13 | Correct | 110 ms | 6620 KB | Output is correct |
14 | Correct | 112 ms | 6648 KB | Output is correct |
15 | Correct | 110 ms | 6648 KB | Output is correct |
16 | Correct | 107 ms | 7388 KB | Output is correct |
17 | Correct | 118 ms | 7364 KB | Output is correct |
18 | Correct | 116 ms | 7800 KB | Output is correct |
19 | Correct | 117 ms | 7916 KB | Output is correct |
20 | Correct | 120 ms | 8304 KB | Output is correct |