Submission #90751

# Submission time Handle Problem Language Result Execution time Memory
90751 2018-12-24T09:07:04 Z YottaByte Schools (IZhO13_school) C++14
20 / 100
2000 ms 9000 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;

vector < pii > v;
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.pb( {a, b} );
		ans += a;
	}
	
	if(m + s == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	
	int cnt = n - m - s;
	while(s--)
	{
		int mx = (int)1e8, id = -1;
		mx = -mx;
		
		for(int i = 0; i < n; i++)
		{
			if(u[i] == 0)
			{
				if(mx < v[i].sc - v[i].fr)
				{
					mx = v[i].sc - v[i].fr;
					id = i;
				}
			}
		}
		
		//cout << id << endl;
		
		u[id] = 1;
		ans += mx;
	}
	
	while(cnt--)
	{
		int mn = (int)1e8, id = -1;
		
		for(int i = 0; i < n; i++)
		{
			if(u[i] == 0)
			{
				if(mn > v[i].fr)
				{
					mn = v[i].fr;
					id = i;
				}
			}
		}
		
		//cout << id << endl;
		
		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
*/

Compilation message

school.cpp:21:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 292 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Incorrect 2 ms 468 KB Output isn't correct
5 Incorrect 2 ms 468 KB Output isn't correct
6 Incorrect 2 ms 544 KB Output isn't correct
7 Incorrect 68 ms 876 KB Output isn't correct
8 Correct 5 ms 876 KB Output is correct
9 Incorrect 11 ms 876 KB Output isn't correct
10 Incorrect 13 ms 876 KB Output isn't correct
11 Incorrect 87 ms 892 KB Output isn't correct
12 Incorrect 88 ms 892 KB Output isn't correct
13 Incorrect 300 ms 1780 KB Output isn't correct
14 Execution timed out 2032 ms 2800 KB Time limit exceeded
15 Execution timed out 2037 ms 4840 KB Time limit exceeded
16 Execution timed out 2045 ms 5004 KB Time limit exceeded
17 Execution timed out 2060 ms 5980 KB Time limit exceeded
18 Execution timed out 2062 ms 6412 KB Time limit exceeded
19 Execution timed out 2070 ms 6964 KB Time limit exceeded
20 Execution timed out 2053 ms 9000 KB Time limit exceeded