# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
18053 | chan492811 | 컬러볼 (KOI15_ball) | C++98 | 117 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;
int n,sum;
struct data{
int z,x,idx;
};
data arr[200010];
int index[200010],color[200010];
bool compare(data d1,data d2){
return d1.x<d2.x;
}
int main(){
int i,j,cnt;
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%d %d",&arr[i].z,&arr[i].x),arr[i].idx=i;
sort(arr+1,arr+n+1,compare); j=0;
for(i=1;i<=n;i++){
if(arr[i].x!=arr[i-1].x){
for(;j<i;j++) sum+=arr[j].x, color[arr[j].z]+=arr[j].x;
}
index[arr[i].idx]=sum-color[arr[i].z];
}
for(i=1;i<=n;i++) printf("%d\n",index[i]);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |