# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
18093 |
2016-01-20T06:03:47 Z |
comet |
컬러볼 (KOI15_ball) |
C++ |
|
202 ms |
20292 KB |
#include <cstdio>
#include <algorithm>
#include <vector>
#define pb push_back
using namespace std;
typedef vector<int> vec;
int N;
vec a[200010],a_sum[200010];
vec s,sum;
int in[200010],in2[200010];
int query(vec& A,vec& B,int c){
int id = upper_bound(A.begin(),A.end(),c-1)-A.begin();
if(id==0)return 0;
return B[id-1];
}
int main(){
scanf("%d",&N);
int x,y;
s.resize(N);
sum.resize(N);
for(int i=0;i<N;i++){
scanf("%d%d",&x,&y);
a[x].pb(y);
s[i]=y;
in[i]=x,in2[i]=y;
}
sort(s.begin(),s.end());
for(int i=0;i<N;i++){
sum[i]=s[i];
if(i)sum[i]+=sum[i-1];
}
for(int i=1;i<=2000;i++){
if(a[i].empty())continue;
sort(a[i].begin(),a[i].end());
a_sum[i].resize(a[i].size());
for(int j=0;j<a[i].size();j++){
a_sum[i][j]=a[i][j];
if(j)a_sum[i][j]+=a_sum[i][j-1];
}
}
for(int i=0;i<N;i++){
printf("%d\n",query(s,sum,in2[i])-query(a[in[i]],a_sum[in[i]],in2[i]));
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
187 ms |
20292 KB |
Output is correct |
2 |
Correct |
202 ms |
20292 KB |
Output is correct |
3 |
Correct |
163 ms |
20292 KB |
Output is correct |
4 |
Correct |
186 ms |
20292 KB |
Output is correct |
5 |
Correct |
195 ms |
20292 KB |
Output is correct |
6 |
Runtime error |
0 ms |
12652 KB |
SIGSEGV Segmentation fault |
7 |
Runtime error |
0 ms |
12652 KB |
SIGSEGV Segmentation fault |
8 |
Runtime error |
0 ms |
12652 KB |
SIGSEGV Segmentation fault |
9 |
Runtime error |
2 ms |
12652 KB |
SIGSEGV Segmentation fault |
10 |
Runtime error |
2 ms |
12652 KB |
SIGSEGV Segmentation fault |
11 |
Correct |
175 ms |
15796 KB |
Output is correct |
12 |
Correct |
179 ms |
15892 KB |
Output is correct |
13 |
Correct |
184 ms |
15800 KB |
Output is correct |
14 |
Correct |
157 ms |
15872 KB |
Output is correct |
15 |
Correct |
184 ms |
15900 KB |
Output is correct |
16 |
Runtime error |
80 ms |
16964 KB |
SIGSEGV Segmentation fault |
17 |
Runtime error |
79 ms |
17232 KB |
SIGSEGV Segmentation fault |
18 |
Runtime error |
91 ms |
17308 KB |
SIGSEGV Segmentation fault |
19 |
Runtime error |
81 ms |
17212 KB |
SIGSEGV Segmentation fault |
20 |
Runtime error |
85 ms |
17520 KB |
SIGSEGV Segmentation fault |