#include <bits/stdc++.h>
using namespace std;
int q1[10001],q2[10001];
int main()
{
int n,x,y,mx1=0,mx2=0,s=1,sum=0;
cin>>n>>x>>y;
pair<int,int> a[n],b[n];
for(int k=0;k<n;k++){
cin>>a[k].first;
cin>>a[k].second;
b[k].first=a[k].second;
b[k].second=a[k].first;
}
sort(a,a+n);
sort(b,b+n);
for(int k=0;k<x;k++){
mx1=mx1+a[n-s].first;
q1[a[n-s].first]=1;
s++;
}
for(int k=n-1;k>=0;k--){
if(sum==y)break;
if(q1[b[k].second]==0){
mx1=mx1+b[k].first;
sum++;
}
}
s=1;
sum=0;
for(int k=0;k<y;k++){
mx2=mx2+b[n-s].first;
q2[b[n-s].first]=1;
s++;
}
for(int k=n-1;k>=0;k--){
if(sum==x)break;
if(q2[a[k].second]==0){
mx2=mx2+a[k].first;
sum++;
}
}
cout<<max(mx1,mx2);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
544 KB |
Output is correct |
4 |
Incorrect |
2 ms |
544 KB |
Output isn't correct |
5 |
Runtime error |
2 ms |
636 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
2 ms |
704 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
6 ms |
936 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
6 ms |
936 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
6 ms |
936 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
6 ms |
936 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
6 ms |
936 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
6 ms |
936 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
35 ms |
1908 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
70 ms |
3188 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Runtime error |
151 ms |
5780 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
165 ms |
6364 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
212 ms |
7624 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
229 ms |
8416 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
253 ms |
9024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
292 ms |
10176 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |