Submission #76453223
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
void O_O() {
int n, k, m;
cin >> n >> k >> m;
array<int, 2> a[n];
for (int i = 0; i < n; i++) {
cin >> a[i][1] >> a[i][0];
}
sort(a, a + n);
long long ans = a[n - 1][0];
bool freq[n + 1];
memset(freq, 0, sizeof freq);
freq[a[n - 1][1]] = 1;
for (int i = n - 2, c = 1; c != m; i--) {
if (!freq[a[i][1]]) {
freq[a[i][1]] = 1;
ans += a[i][0];
a[i][0] = -1;
c++;
}
}
for (int i = n - 2, c = 0; c < k - m; i--) {
if (~a[i][0]) {
ans += a[i][0];
c++;
}
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int TC = 1;
// cin >> TC;
while (TC--) {
O_O();
if (TC) cout << '\n';
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Variety |
| User | Mariouma |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 928 Byte |
| Status | AC |
| Exec Time | 28 ms |
| Memory | 5388 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| All | 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, sample-01.txt, sample-02.txt, sample-03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 04.txt | AC | 1 ms | 3528 KiB |
| 05.txt | AC | 17 ms | 5332 KiB |
| 06.txt | AC | 17 ms | 5340 KiB |
| 07.txt | AC | 14 ms | 5296 KiB |
| 08.txt | AC | 1 ms | 3432 KiB |
| 09.txt | AC | 1 ms | 3432 KiB |
| 10.txt | AC | 1 ms | 3644 KiB |
| 11.txt | AC | 11 ms | 4328 KiB |
| 12.txt | AC | 27 ms | 5388 KiB |
| 13.txt | AC | 28 ms | 5344 KiB |
| 14.txt | AC | 28 ms | 5220 KiB |
| 15.txt | AC | 28 ms | 5208 KiB |
| 16.txt | AC | 28 ms | 5296 KiB |
| 17.txt | AC | 28 ms | 5296 KiB |
| 18.txt | AC | 27 ms | 5224 KiB |
| 19.txt | AC | 28 ms | 5296 KiB |
| 20.txt | AC | 28 ms | 5296 KiB |
| 21.txt | AC | 27 ms | 5276 KiB |
| 22.txt | AC | 27 ms | 5372 KiB |
| 23.txt | AC | 27 ms | 5344 KiB |
| sample-01.txt | AC | 1 ms | 3504 KiB |
| sample-02.txt | AC | 1 ms | 3596 KiB |
| sample-03.txt | AC | 1 ms | 3376 KiB |