Submission #76439315
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
bool st;
int n,m,k;
struct node{int c,v;}a[N];
bool cmp(node a,node b) {
if(a.v==b.v) return a.c>b.c;
return a.v>b.v;
}bool used[N];
bool ed;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cerr<<(double)(&st-&ed)/1024/1024<<'\n';
cin>>n>>k>>m;
for(int i=1;i<=n;i++) {cin>>a[i].c>>a[i].v;}
sort(a+1,a+n+1,cmp);
int cnt=0,col=0,ans=0;
for(int i=1;i<=n;i++) {
if(!used[a[i].c]) {
used[a[i].c]=1,cnt++,col++;ans+=a[i].v;
}else if(m-col!=k-cnt){
cnt++,ans+=a[i].v;
}
if(cnt==k) {break;}
}cout<<ans<<'\n';
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Variety |
| User | wallacewan |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 683 Byte |
| Status | AC |
| Exec Time | 32 ms |
| Memory | 7232 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 | 3676 KiB |
| 05.txt | AC | 18 ms | 6972 KiB |
| 06.txt | AC | 17 ms | 7120 KiB |
| 07.txt | AC | 22 ms | 7136 KiB |
| 08.txt | AC | 1 ms | 3688 KiB |
| 09.txt | AC | 1 ms | 3936 KiB |
| 10.txt | AC | 1 ms | 3988 KiB |
| 11.txt | AC | 12 ms | 5216 KiB |
| 12.txt | AC | 28 ms | 6932 KiB |
| 13.txt | AC | 29 ms | 7100 KiB |
| 14.txt | AC | 30 ms | 7092 KiB |
| 15.txt | AC | 29 ms | 7088 KiB |
| 16.txt | AC | 29 ms | 7076 KiB |
| 17.txt | AC | 30 ms | 7232 KiB |
| 18.txt | AC | 28 ms | 7004 KiB |
| 19.txt | AC | 30 ms | 7100 KiB |
| 20.txt | AC | 32 ms | 7088 KiB |
| 21.txt | AC | 29 ms | 6948 KiB |
| 22.txt | AC | 31 ms | 7004 KiB |
| 23.txt | AC | 29 ms | 7168 KiB |
| sample-01.txt | AC | 1 ms | 3648 KiB |
| sample-02.txt | AC | 1 ms | 3748 KiB |
| sample-03.txt | AC | 1 ms | 3724 KiB |