Submission #90756

# Submission time Handle Problem Language Result Execution time Memory
90756 2018-12-24T09:24:44 Z YottaByte Schools (IZhO13_school) C++14
25 / 100
329 ms 23316 KB
#include <algorithm>
#include <iostream>
#include <queue>

using namespace std;

#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
#define int long long
#define pii pair < int, int >

const int N = 3e5 + 1;

priority_queue < pair < pii, pii > > v;
priority_queue < pair < int, pii >, vector < pair < int, pii > >, greater < pair < int, pii > > > pq;
ll ans;
int u[N];

main()
{
	int n, m, s;
	cin >> n >> m >> s;
	for(int i = 1; i <= n; i++)
	{
		int a, b;
		cin >> a >> b;
		v.push( { {b - a, i}, {a, b} } );
		pq.push( { a, { b, i } } );
		ans += a;
	}
	
	int cnt = n - m - s;
	while(s--)
	{
		int mx = v.top().fr.fr, id = v.top().fr.sc;
		
		v.pop();
		
		u[id] = 1;
		
		//cout << id + 1 << endl;
		
		u[id] = 1;
		ans += mx;
	}
	
	while(cnt)
	{
		int id = pq.top().sc.sc;
		int mn = pq.top().fr;
		pq.pop();
		
		if(u[id]) continue;
		
	//puts("Del");
		//cout << id + 1 << endl;
		
		cnt--;
		u[id] = 1;
		ans -= mn;
	}
	
	cout << ans << endl;
}
/*
3 1 1
5 2
4 1
6 4

7 2 3
9 8
10 6
3 5
1 7
5 7
6 3
5 4

5 1 1
6 16
2 14
4 5
4 19
15 19
*/

Compilation message

school.cpp:22:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Incorrect 2 ms 508 KB Output isn't correct
5 Incorrect 2 ms 508 KB Output isn't correct
6 Incorrect 2 ms 508 KB Output isn't correct
7 Incorrect 5 ms 868 KB Output isn't correct
8 Correct 5 ms 888 KB Output is correct
9 Incorrect 5 ms 888 KB Output isn't correct
10 Incorrect 5 ms 888 KB Output isn't correct
11 Incorrect 6 ms 900 KB Output isn't correct
12 Incorrect 6 ms 932 KB Output isn't correct
13 Incorrect 27 ms 3484 KB Output isn't correct
14 Incorrect 73 ms 6364 KB Output isn't correct
15 Incorrect 150 ms 11992 KB Output isn't correct
16 Correct 171 ms 12096 KB Output is correct
17 Incorrect 219 ms 14412 KB Output isn't correct
18 Incorrect 249 ms 15868 KB Output isn't correct
19 Incorrect 268 ms 17024 KB Output isn't correct
20 Incorrect 329 ms 23316 KB Output isn't correct