Submission #18854

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