# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145559 | 2019-08-20T11:45:54 Z | surface03 | 컬러볼 (KOI15_ball) | C++14 | 95 ms | 8312 KB |
#include<stdio.h> #include<algorithm> using namespace std; struct data{ int num,color,size; bool operator<(const data &r) const{ return size<r.size; } }ball[200010]; int N,score[200010],sum[200010]; int main(){ int i,j; scanf("%d",&N); for(i=0;i<N;i++){ scanf("%d%d",&ball[i].color,&ball[i].size); ball[i].num=i; } sort(ball,ball+N); for(i=0,j=0;i<N;i++){ while(j<i&&ball[j].size<ball[i].size){ sum[0]+=ball[j].size,sum[ball[j].color]+=ball[j].size; j++; } score[ball[i].num]=sum[0]-sum[ball[i].color]; } for(i=0;i<N;i++){ printf("%d\n",score[i]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 91 ms | 8312 KB | Output is correct |
2 | Correct | 91 ms | 8184 KB | Output is correct |
3 | Correct | 91 ms | 8152 KB | Output is correct |
4 | Correct | 92 ms | 8056 KB | Output is correct |
5 | Correct | 92 ms | 8212 KB | Output is correct |
6 | Correct | 4 ms | 504 KB | Output is correct |
7 | Correct | 4 ms | 504 KB | Output is correct |
8 | Correct | 4 ms | 504 KB | Output is correct |
9 | Correct | 4 ms | 632 KB | Output is correct |
10 | Correct | 4 ms | 504 KB | Output is correct |
11 | Correct | 82 ms | 6648 KB | Output is correct |
12 | Correct | 82 ms | 6648 KB | Output is correct |
13 | Correct | 81 ms | 6776 KB | Output is correct |
14 | Correct | 81 ms | 6672 KB | Output is correct |
15 | Correct | 82 ms | 6776 KB | Output is correct |
16 | Correct | 82 ms | 7440 KB | Output is correct |
17 | Correct | 82 ms | 7416 KB | Output is correct |
18 | Correct | 87 ms | 7772 KB | Output is correct |
19 | Correct | 95 ms | 8044 KB | Output is correct |
20 | Correct | 93 ms | 8124 KB | Output is correct |