Submission #164411

# Submission time Handle Problem Language Result Execution time Memory
164411 2019-11-20T13:24:24 Z tselmegkh Schools (IZhO13_school) C++14
30 / 100
616 ms 16448 KB
	#include<bits/stdc++.h>
	using namespace std;

	const int N = 3e5 + 5;
	int sum[N][2];

	int main(){
		int n, m, s;
		cin >> n >> m >> s;
		
		vector<pair<int, int>> v1, v2;
		for(int i = 0; i < n; i++){
			int a, b;
			cin >> a >> b;
			v1.push_back({a - b, a});
			v2.push_back({b - a, b});
		}
		sort(v1.rbegin(), v1.rend());
		sort(v2.rbegin(), v2.rend());

		int tot = 0;
		multiset<int> ms;
		for(int i = 0; i < n; i++){
			ms.insert(v1[i].second);
			tot += v1[i].second;
			if(ms.size() > m){
				tot -= *ms.begin();
				ms.erase(ms.begin());
			}
			sum[i + 1][0] = tot;
		}
		tot = 0;
		ms.clear();
		for(int i = 0; i < n; i++){
			ms.insert(v2[i].second);
			tot += v2[i].second;
			if(ms.size() > s){
				tot -= *ms.begin();
				ms.erase(ms.begin());
			}
			sum[i + 1][1] = tot;
		}
		int ans = 0;
		for(int i = m; i <= n - s; i++){
			ans = max(ans, sum[i][0] + sum[n - i - 1][1]);
		}
		cout << ans << '\n';
	}

Compilation message

school.cpp: In function 'int main()':
school.cpp:26:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(ms.size() > m){
       ~~~~~~~~~~^~~
school.cpp:37:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(ms.size() > s){
       ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Correct 8 ms 632 KB Output is correct
8 Incorrect 9 ms 760 KB Output isn't correct
9 Incorrect 11 ms 632 KB Output isn't correct
10 Correct 10 ms 760 KB Output is correct
11 Incorrect 10 ms 632 KB Output isn't correct
12 Correct 9 ms 632 KB Output is correct
13 Incorrect 61 ms 3100 KB Output isn't correct
14 Incorrect 122 ms 4040 KB Output isn't correct
15 Correct 216 ms 6180 KB Output is correct
16 Incorrect 367 ms 14056 KB Output isn't correct
17 Incorrect 449 ms 13196 KB Output isn't correct
18 Incorrect 460 ms 13340 KB Output isn't correct
19 Incorrect 483 ms 14312 KB Output isn't correct
20 Incorrect 616 ms 16448 KB Output isn't correct