Submission #655083

# Submission time Handle Problem Language Result Execution time Memory
655083 2022-11-03T01:34:35 Z as111 Schools (IZhO13_school) C++17
15 / 100
210 ms 14976 KB
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#define MAXN 300000
#define s second
#define f first

using namespace std;
int cities[MAXN + 1][2];
bool used[MAXN + 1]; // city used or not
vector<pair<int, pair<int, int>>> music;
vector<pair<int, pair<int, int>>> sports;
int N;
int mpos = N - 1;
int spos = N - 1;
void findM() {
	while (used[music[mpos].s.s] && mpos != 0) mpos--;
}
void findS() {
	while (used[sports[spos].s.s]) spos--;
}
int main() {
	int M, S;
	cin >> N >> M >> S;
	for (int i = 0; i < N; i++) {
		cin >> cities[i][0] >> cities[i][1];
		music.push_back(make_pair(cities[i][0], make_pair(cities[i][1], i)));
		sports.push_back(make_pair(cities[i][1], make_pair(cities[i][0], i)));
	}
	sort(music.begin(), music.end());
	sort(sports.begin(), sports.end());
	int ans = 0;
	mpos = N - 1;
	spos = N - 1;
	while (M > 0) {
		used[music[mpos].s.s] = true;
		ans += music[mpos].f;
		findM();
		M--;
	}
	while (S > 0) {
		int pos = sports[spos].s.s;
		if (used[pos]) {
			findM();
			if (cities[pos][1]+music[mpos].f > cities[pos][0]) {
				ans += cities[pos][1] + music[mpos].f - cities[pos][0];
				used[music[mpos].s.s] = true;
				spos--;
				S--;
			}
			else {
				spos--;
			}
		}
		else {
			ans += sports[spos].f;
			used[sports[spos].s.s] = true;
			spos--;
			S--;
		}
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Incorrect 1 ms 356 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 4 ms 576 KB Output isn't correct
8 Incorrect 3 ms 596 KB Output isn't correct
9 Incorrect 3 ms 560 KB Output isn't correct
10 Incorrect 3 ms 596 KB Output isn't correct
11 Incorrect 3 ms 596 KB Output isn't correct
12 Incorrect 3 ms 596 KB Output isn't correct
13 Incorrect 24 ms 2172 KB Output isn't correct
14 Incorrect 54 ms 4212 KB Output isn't correct
15 Correct 108 ms 7700 KB Output is correct
16 Incorrect 120 ms 8176 KB Output isn't correct
17 Incorrect 153 ms 10064 KB Output isn't correct
18 Incorrect 168 ms 10952 KB Output isn't correct
19 Incorrect 180 ms 11816 KB Output isn't correct
20 Incorrect 210 ms 14976 KB Output isn't correct