Submission #84461

# Submission time Handle Problem Language Result Execution time Memory
84461 2018-11-15T09:00:39 Z hamzqq9 Schools (IZhO13_school) C++14
25 / 100
173 ms 6984 KB
#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

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 time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Incorrect 2 ms 528 KB Output isn't correct
5 Incorrect 2 ms 528 KB Output isn't correct
6 Incorrect 2 ms 528 KB Output isn't correct
7 Incorrect 4 ms 532 KB Output isn't correct
8 Correct 3 ms 584 KB Output is correct
9 Incorrect 4 ms 584 KB Output isn't correct
10 Incorrect 4 ms 712 KB Output isn't correct
11 Incorrect 4 ms 712 KB Output isn't correct
12 Incorrect 4 ms 712 KB Output isn't correct
13 Incorrect 14 ms 1492 KB Output isn't correct
14 Incorrect 46 ms 2292 KB Output isn't correct
15 Incorrect 99 ms 3892 KB Output isn't correct
16 Correct 105 ms 4268 KB Output is correct
17 Incorrect 146 ms 5016 KB Output isn't correct
18 Incorrect 132 ms 5500 KB Output isn't correct
19 Incorrect 143 ms 5812 KB Output isn't correct
20 Incorrect 173 ms 6984 KB Output isn't correct