Submission #278655

# Submission time Handle Problem Language Result Execution time Memory
278655 2020-08-21T16:07:17 Z keta_tsimakuridze Schools (IZhO13_school) C++14
5 / 100
201 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;
	}//cout<<cur.size()<<endl;
	ans[n-n2+1]=curAns;
	for(k=n-n2;k>n1;k--){
		ans1[k]=ans1[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 0 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 0 ms 384 KB Output isn't correct
5 Incorrect 0 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 2 ms 640 KB Output isn't correct
9 Incorrect 3 ms 640 KB Output isn't correct
10 Incorrect 4 ms 640 KB Output isn't correct
11 Incorrect 4 ms 640 KB Output isn't correct
12 Incorrect 3 ms 640 KB Output isn't correct
13 Incorrect 21 ms 2688 KB Output isn't correct
14 Incorrect 40 ms 3960 KB Output isn't correct
15 Incorrect 61 ms 6716 KB Output isn't correct
16 Incorrect 134 ms 12024 KB Output isn't correct
17 Incorrect 146 ms 10872 KB Output isn't correct
18 Incorrect 154 ms 11412 KB Output isn't correct
19 Incorrect 172 ms 12312 KB Output isn't correct
20 Incorrect 201 ms 14200 KB Output isn't correct