# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145559 | surface03 | 컬러볼 (KOI15_ball) | C++14 | 95 ms | 8312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |