# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
18468 | eaststar | 컬러볼 (KOI15_ball) | C++14 | 123 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 <stdio.h>
#include <algorithm>
using namespace std;
struct data{
int c,s,i;
bool operator<(const data&r)const{
if(s==r.s)return c<r.c;
return s<r.s;
}
}a[200010];
int sum[200010],ans[200010],s;
int main(){
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;++i)scanf("%d%d",&a[i].c,&a[i].s),a[i].i=i;
sort(a+1,a+n+1);
for(i=2,j=1;i<=n;++i){
while(a[j].s<a[i].s)sum[a[j].c]+=a[j].s,s+=a[j++].s;
ans[a[i].i]=s-sum[a[i].c];
}
for(i=1;i<=n;++i)printf("%d\n",ans[i]);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |