Submission #76482668
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, K, M;
cin >> N >> K >> M;
vector<pair<long long,long long>> C(N);
for(int i=0;i<N;i++){
cin >> C[i].first >> C[i].second;
swap(C[i].first, C[i].second); // (価値,色)
}
long long ans = 0;
set<long long> A;
sort(C.rbegin(), C.rend());
for(int i=0;i<K;i++){
ans += C[i].first;
A.insert(C[i].second);
}
// 上位K個を削除
C.erase(C.begin(), C.begin() + K);
// Aに含まれる色の宝石を削除
C.erase(
remove_if(
C.begin(),
C.end(),
[&](const pair<long long,long long>& p){
return A.count(p.second);
}
),
C.end()
);
if((int)A.size() >= M){
cout << ans << endl;
}
else{
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Variety |
| User | naka0713 |
| Language | C++23 (GCC 15.2.0) |
| Score | 0 |
| Code Size | 904 Byte |
| Status | WA |
| Exec Time | 127 ms |
| Memory | 15788 KiB |
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 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 | 3464 KiB |
| 05.txt | AC | 87 ms | 6512 KiB |
| 06.txt | AC | 116 ms | 15696 KiB |
| 07.txt | WA | 66 ms | 6464 KiB |
| 08.txt | WA | 1 ms | 3512 KiB |
| 09.txt | WA | 1 ms | 3472 KiB |
| 10.txt | WA | 3 ms | 3668 KiB |
| 11.txt | WA | 47 ms | 6352 KiB |
| 12.txt | WA | 121 ms | 10140 KiB |
| 13.txt | AC | 127 ms | 10312 KiB |
| 14.txt | WA | 126 ms | 10180 KiB |
| 15.txt | AC | 111 ms | 9608 KiB |
| 16.txt | AC | 102 ms | 7016 KiB |
| 17.txt | WA | 106 ms | 7256 KiB |
| 18.txt | WA | 92 ms | 6444 KiB |
| 19.txt | WA | 104 ms | 7072 KiB |
| 20.txt | WA | 106 ms | 7452 KiB |
| 21.txt | AC | 92 ms | 6352 KiB |
| 22.txt | WA | 82 ms | 15788 KiB |
| 23.txt | WA | 99 ms | 6528 KiB |
| sample-01.txt | WA | 1 ms | 3408 KiB |
| sample-02.txt | WA | 1 ms | 3460 KiB |
| sample-03.txt | AC | 1 ms | 3508 KiB |