Submission #76450448
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 2e5+5;
int n, k, m;
vector<int> a[MAXN];
bool comp(int x, int y)
{
return x>y;
}
signed main(){
cin >> n >> k >> m;
for (int i=1; i<=n; i++)
{
int c, v;
cin >> c >> v;
a[c].push_back(v);
}
for (int i=1; i<=n; i++)
if (a[i].size()>0) sort(a[i].begin(), a[i].end(), comp);
vector<int> x, y;
for (int i=1; i<=n; i++)
if (a[i].size()>0)
{
x.push_back(a[i][0]);
for (int j=1; j<a[i].size(); j++) y.push_back(a[i][j]);
}
sort(x.begin(), x.end(), comp);
int ans = 0;
for (int i=0; i<m; i++) ans+=x[i];
for (int i=m; i<x.size(); i++) y.push_back(x[i]);
sort(y.begin(), y.end(), comp);
k-=m;
for (int i=0; i<k; i++) ans+=y[i];
cout << ans;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Variety |
| User | nxzwcry |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 813 Byte |
| Status | AC |
| Exec Time | 114 ms |
| Memory | 16604 KiB |
Compile Error
./Main.cpp: In function 'int main()':
./Main.cpp:29:40: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for (int j=1; j<a[i].size(); j++) y.push_back(a[i][j]);
| ~^~~~~~~~~~~~
./Main.cpp:34:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for (int i=m; i<x.size(); i++) y.push_back(x[i]);
| ~^~~~~~~~~
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 | 2 ms | 3496 KiB |
| 05.txt | AC | 92 ms | 7904 KiB |
| 06.txt | AC | 97 ms | 16604 KiB |
| 07.txt | AC | 66 ms | 11992 KiB |
| 08.txt | AC | 2 ms | 3556 KiB |
| 09.txt | AC | 2 ms | 3608 KiB |
| 10.txt | AC | 3 ms | 3736 KiB |
| 11.txt | AC | 45 ms | 8124 KiB |
| 12.txt | AC | 107 ms | 13988 KiB |
| 13.txt | AC | 112 ms | 14284 KiB |
| 14.txt | AC | 111 ms | 14324 KiB |
| 15.txt | AC | 110 ms | 14096 KiB |
| 16.txt | AC | 108 ms | 13676 KiB |
| 17.txt | AC | 106 ms | 14244 KiB |
| 18.txt | AC | 105 ms | 14232 KiB |
| 19.txt | AC | 108 ms | 13584 KiB |
| 20.txt | AC | 107 ms | 14320 KiB |
| 21.txt | AC | 114 ms | 15424 KiB |
| 22.txt | AC | 60 ms | 16484 KiB |
| 23.txt | AC | 107 ms | 13968 KiB |
| sample-01.txt | AC | 2 ms | 3476 KiB |
| sample-02.txt | AC | 2 ms | 3416 KiB |
| sample-03.txt | AC | 2 ms | 3480 KiB |