Submission #278642

# Submission time Handle Problem Language Result Execution time Memory
278642 2020-08-21T15:58:58 Z keta_tsimakuridze Schools (IZhO13_school) C++14
5 / 100
211 ms 14200 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;
	}
	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;
			
		}
	}
	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 640 KB Output isn't correct
8 Incorrect 4 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 4 ms 640 KB Output isn't correct
12 Incorrect 4 ms 640 KB Output isn't correct
13 Incorrect 21 ms 2672 KB Output isn't correct
14 Incorrect 39 ms 3960 KB Output isn't correct
15 Incorrect 62 ms 6792 KB Output isn't correct
16 Incorrect 135 ms 12024 KB Output isn't correct
17 Incorrect 149 ms 10872 KB Output isn't correct
18 Incorrect 169 ms 11460 KB Output isn't correct
19 Incorrect 178 ms 12244 KB Output isn't correct
20 Incorrect 211 ms 14200 KB Output isn't correct