Submission #278650

# Submission time Handle Problem Language Result Execution time Memory
278650 2020-08-21T16:05:11 Z keta_tsimakuridze Schools (IZhO13_school) C++14
5 / 100
202 ms 14336 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];
multiset<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;
	}
	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.find(*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;
	}//cout<<cur.size()<<endl;
	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.find(*cur.begin()));
			cur.insert(p[k].s.s);
			ans1[k]+=p[k].s.s;
			
		}
	}curAns=0;
	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 1 ms 384 KB Output isn't correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Incorrect 1 ms 384 KB Output isn't correct
7 Incorrect 2 ms 512 KB Output isn't correct
8 Incorrect 3 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 22 ms 2688 KB Output isn't correct
14 Incorrect 39 ms 3968 KB Output isn't correct
15 Incorrect 64 ms 6904 KB Output isn't correct
16 Incorrect 141 ms 12028 KB Output isn't correct
17 Incorrect 141 ms 10876 KB Output isn't correct
18 Incorrect 162 ms 11512 KB Output isn't correct
19 Incorrect 171 ms 12280 KB Output isn't correct
20 Incorrect 202 ms 14336 KB Output isn't correct