Submission #45320217


Source Code Expand

#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	int n, m, a, b;
	cin >> n >> m >> a >> b;
	vector<int> cnt(n, 0);
	for (int i = 0; i < m; ++i) {
		int x;
		cin >> x;
		--x;
		++cnt[x];
	}
	sort(ALL(cnt));
	int cur = b;
	int ans = n;
	for (int x : cnt) {
		if (x <= cur) {
			cur -= x;
			ans -= 1;
		}
	}
	ans = min(ans, a - b);
	cout << n - ans << "\n";
	return 0;
}


Submission Info

Submission Time
Task A - Save the Monsters
User LHiC
Language C++ 20 (gcc 12.2)
Score 500
Code Size 902 Byte
Status AC
Exec Time 18 ms
Memory 4172 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 4
AC × 35
Set Name Test Cases
Sample 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt
All 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt
Case Name Status Exec Time Memory
00-sample-001.txt AC 1 ms 3480 KiB
00-sample-002.txt AC 1 ms 3496 KiB
00-sample-003.txt AC 1 ms 3476 KiB
00-sample-004.txt AC 1 ms 3480 KiB
01-001.txt AC 1 ms 3496 KiB
01-002.txt AC 1 ms 3492 KiB
01-003.txt AC 1 ms 3444 KiB
01-004.txt AC 1 ms 3432 KiB
01-005.txt AC 1 ms 3504 KiB
01-006.txt AC 9 ms 3524 KiB
01-007.txt AC 17 ms 3824 KiB
01-008.txt AC 11 ms 3512 KiB
01-009.txt AC 9 ms 3476 KiB
01-010.txt AC 9 ms 3536 KiB
01-011.txt AC 13 ms 4152 KiB
01-012.txt AC 18 ms 4136 KiB
01-013.txt AC 6 ms 4116 KiB
01-014.txt AC 16 ms 4048 KiB
01-015.txt AC 16 ms 4172 KiB
01-016.txt AC 12 ms 3432 KiB
01-017.txt AC 18 ms 3828 KiB
01-018.txt AC 14 ms 3608 KiB
01-019.txt AC 12 ms 3468 KiB
01-020.txt AC 15 ms 3560 KiB
01-021.txt AC 18 ms 4128 KiB
01-022.txt AC 18 ms 4108 KiB
01-023.txt AC 18 ms 4080 KiB
01-024.txt AC 18 ms 4072 KiB
01-025.txt AC 18 ms 4088 KiB
01-026.txt AC 1 ms 3556 KiB
01-027.txt AC 8 ms 3444 KiB
01-028.txt AC 3 ms 4172 KiB
01-029.txt AC 8 ms 3500 KiB
01-030.txt AC 10 ms 3448 KiB
01-031.txt AC 12 ms 3576 KiB