# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
18053 |
2016-01-19T10:11:35 Z |
chan492811 |
컬러볼 (KOI15_ball) |
C++ |
|
117 ms |
4988 KB |
#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 |
1 |
Correct |
74 ms |
4988 KB |
Output is correct |
2 |
Correct |
102 ms |
4988 KB |
Output is correct |
3 |
Correct |
99 ms |
4988 KB |
Output is correct |
4 |
Correct |
77 ms |
4988 KB |
Output is correct |
5 |
Correct |
92 ms |
4988 KB |
Output is correct |
6 |
Correct |
0 ms |
4988 KB |
Output is correct |
7 |
Correct |
0 ms |
4988 KB |
Output is correct |
8 |
Correct |
0 ms |
4988 KB |
Output is correct |
9 |
Correct |
1 ms |
4988 KB |
Output is correct |
10 |
Correct |
3 ms |
4988 KB |
Output is correct |
11 |
Correct |
117 ms |
4988 KB |
Output is correct |
12 |
Correct |
76 ms |
4988 KB |
Output is correct |
13 |
Correct |
76 ms |
4988 KB |
Output is correct |
14 |
Correct |
102 ms |
4988 KB |
Output is correct |
15 |
Correct |
75 ms |
4988 KB |
Output is correct |
16 |
Correct |
64 ms |
4988 KB |
Output is correct |
17 |
Correct |
86 ms |
4988 KB |
Output is correct |
18 |
Correct |
89 ms |
4988 KB |
Output is correct |
19 |
Correct |
90 ms |
4988 KB |
Output is correct |
20 |
Correct |
81 ms |
4988 KB |
Output is correct |