Submission #18468

#TimeUsernameProblemLanguageResultExecution timeMemory
18468eaststar컬러볼 (KOI15_ball)C++14
25 / 25
123 ms4988 KiB
#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 timeMemoryGrader output
Fetching results...