Submission #18090

# Submission time Handle Problem Language Result Execution time Memory
18090 2016-01-20T05:51:25 Z comet 컬러볼 (KOI15_ball) C++
0 / 25
77 ms 131072 KB
#include <cstdio>
#include <algorithm>
#include <vector>
#define pb push_back
using namespace std;
typedef vector<int> vec;

int N;
vec a[2010],s;
vec a_sum[2010],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<=N;i++){
		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 Runtime error 0 ms 4800 KB SIGSEGV Segmentation fault
2 Runtime error 0 ms 4800 KB SIGSEGV Segmentation fault
3 Runtime error 0 ms 4800 KB SIGSEGV Segmentation fault
4 Runtime error 0 ms 4800 KB SIGSEGV Segmentation fault
5 Runtime error 1 ms 4800 KB SIGSEGV Segmentation fault
6 Memory limit exceeded 2 ms 131072 KB Memory limit exceeded
7 Runtime error 2 ms 3364 KB SIGSEGV Segmentation fault
8 Runtime error 0 ms 3364 KB SIGSEGV Segmentation fault
9 Runtime error 0 ms 3364 KB SIGSEGV Segmentation fault
10 Memory limit exceeded 2 ms 131072 KB Memory limit exceeded
11 Runtime error 68 ms 6508 KB SIGSEGV Segmentation fault
12 Runtime error 68 ms 6604 KB SIGSEGV Segmentation fault
13 Runtime error 73 ms 6512 KB SIGSEGV Segmentation fault
14 Runtime error 77 ms 6584 KB SIGSEGV Segmentation fault
15 Runtime error 77 ms 6612 KB SIGSEGV Segmentation fault
16 Runtime error 1 ms 4640 KB SIGSEGV Segmentation fault
17 Runtime error 0 ms 4648 KB SIGSEGV Segmentation fault
18 Runtime error 1 ms 4720 KB SIGSEGV Segmentation fault
19 Runtime error 0 ms 4760 KB SIGSEGV Segmentation fault
20 Runtime error 0 ms 4800 KB SIGSEGV Segmentation fault