Submission #84461

#TimeUsernameProblemLanguageResultExecution timeMemory
84461hamzqq9Schools (IZhO13_school)C++14
25 / 100
173 ms6984 KiB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2005000000
#define MOD 1000000007
#define N 300005
#define M 1000005
#define LOG 18
#define KOK 4000000
using namespace std;

int n,m,s,x,y,no,se,u[N];
ll ans;
priority_queue<ii> q1,q2;

int main() {

	//freopen("input.txt","r",stdin);
	
	scanf("%d %d %d",&n,&m,&s);

	for(int i=1;i<=n;i++) {

		scanf("%d %d",&x,&y);

		ans+=x;

		q1.push({y-x,i});
		q2.push({-x,i});	

	}

	while(no+se<n-m) {

		while(sz(q1) && u[q1.top().nd]) q1.pop();
		while(sz(q2) && u[q2.top().nd]) q2.pop();

		if(!sz(q2) || no==n-m-s || (se<s && sz(q1) && q2.top().st<q1.top().st)) {

			ans+=q1.top().st;

			u[q1.top().nd]=1;

			q1.pop();

			se++;

		}
		else {

			ans+=q2.top().st;

			u[q2.top().nd]=1;

			q2.pop();

			no++;

		}

	}

	printf("%lld",ans);


}

Compilation message (stderr)

school.cpp: In function 'int main()':
school.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&m,&s);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
school.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&x,&y);
   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...