Submission #278624

# Submission time Handle Problem Language Result Execution time Memory
278624 2020-08-21T15:46:13 Z keta_tsimakuridze Schools (IZhO13_school) C++14
5 / 100
111 ms 11000 KB
#include<bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int N=3e5+5;
int a,b,n,n1,n2,k,curAns,Cc,c,i,ans1[N],ans[N];
pair<int,pair<int,int> >p[N];
set<int > cur;
 main(){
 	ios_base::sync_with_stdio(false);
	cin>>n>>n1>>n2;
	for(k=1;k<=n;k++){
		cin>>a>>b;
		p[k]={a-b,{a,b}};
	}
	sort(p+1,p+n+1);
	reverse(p+1,p+n+1);
	for(k=1;k<=n1;k++){
		 cur.insert(p[k].s.f);
		 curAns+=p[k].s.f;
	}//cout<<curAns<<endl;
	ans[n1]=curAns;
	for(k=n1+1;k<=n-n2;k++){
		ans[k]=ans[k-1]; 
		if((*cur.begin())<=p[k].s.f){
			ans[k]-=(*cur.begin());
			cur.erase(*cur.begin());
			cur.insert(p[k].s.f);
			ans[k]+=p[k].s.f;
			
		}//cout<<k<<" "<<ans[k]<<endl;
	}cur.clear();curAns=0;
	for(k=n;k>=n-n2+1;k--){
		cur.insert(p[k].s.s);
		curAns+=p[k].s.s;
	}
	ans[n-n2+1]=curAns;
	for(k=n-n2;k>n1;k--){
		ans1[k]=ans[k+1];
		if((*cur.begin())<=p[k].s.s){
			ans1[k]-=(*cur.begin());
			cur.erase(*cur.begin());
			cur.insert(p[k].s.s);
			ans1[k]+=p[k].s.s;
			
		}
	}
	for(k=n1;k<=n-n2;k++){
	curAns=max(curAns,ans[k]+ans1[k+1]);	
	}
	
	cout<<curAns<<endl;
	
}

Compilation message

school.cpp:10:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 |  main(){
      |       ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 0 ms 384 KB Output isn't correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Incorrect 0 ms 384 KB Output isn't correct
7 Incorrect 2 ms 512 KB Output isn't correct
8 Incorrect 2 ms 640 KB Output isn't correct
9 Incorrect 3 ms 640 KB Output isn't correct
10 Incorrect 3 ms 640 KB Output isn't correct
11 Incorrect 3 ms 640 KB Output isn't correct
12 Incorrect 3 ms 640 KB Output isn't correct
13 Incorrect 26 ms 2168 KB Output isn't correct
14 Incorrect 34 ms 3576 KB Output isn't correct
15 Incorrect 54 ms 7176 KB Output isn't correct
16 Incorrect 94 ms 6756 KB Output isn't correct
17 Incorrect 88 ms 7196 KB Output isn't correct
18 Incorrect 96 ms 8568 KB Output isn't correct
19 Incorrect 96 ms 9208 KB Output isn't correct
20 Incorrect 111 ms 11000 KB Output isn't correct