Submission #145559

#TimeUsernameProblemLanguageResultExecution timeMemory
145559surface03컬러볼 (KOI15_ball)C++14
25 / 25
95 ms8312 KiB
#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)

ball.cpp: In function 'int main()':
ball.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
ball.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&ball[i].color,&ball[i].size);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...