# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
18854 | Namnamseo | 컬러볼 (KOI15_ball) | C++14 | 108 ms | 4988 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 <cstdio>
#include <algorithm>
using namespace std;
struct ball {
int size, c, ind;
} d[200010];
int n;
int ans[200010];
int cc[200010];
int main()
{
scanf("%d",&n);
int a,b;
int i;
for(i=0;i<n;++i){
scanf("%d%d",&a,&b);
d[i]={b,a,i};
}
sort(d,d+n,[](const ball& a,const ball& b){ return a.size<b.size; });
int j=0;
int ss=0;
for(i=0;i<n;++i){
while(j<n && d[j].size<d[i].size){
cc[d[j].c]+=d[j].size;
ss+=d[j].size;
++j;
}
ans[d[i].ind] = ss-cc[d[i].c];
}
for(i=0;i<n;++i) printf("%d\n",ans[i]);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |