#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PUT(a, b) freopen(a, "r", stdin); freopen(b, "w", stdout);
#define all(a) a.begin(), a.end()
#define answerNO {cout << "NO" << endl; return;}
#define answerYES {cout << "YES" << endl; return;}
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll mod = 1e9 + 7;
void solve(){
ll n, m, s; cin >> n >> m >> s;
vector<pair<pair<ll, ll>, int>> a(n), b(n);
rep(i, n){
cin >> a[i].ff.ff >> a[i].ff.ss;
b[i].ff.ff = a[i].ff.ss;
b[i].ff.ss = a[i].ff.ff;
a[i].ss = i;
b[i].ss = i;
}
sort(all(a));
sort(all(b));
reverse(all(a));
reverse(all(b));
vector<bool> vis(1e5 + 26, 0);
ll ans1 = 0, ans2 = 0;
replr(i, 0, m - 1){
ans1 += a[i].ff.ff;
vis[a[i].ss] = 1;
}
ll cnt = 0;
rep(i, n){
if(!vis[b[i].ss] && cnt < s){
ans1 += b[i].ff.ff;
cnt++;
}
}
vis = vector<bool>(1e5 + 26, 0);
replr(i, 0, s - 1){
ans2 += b[i].ff.ff;
vis[b[i].ss] = 1;
}
cnt = 0;
rep(i, n){
if(cnt < m && !vis[a[i].ss]){
ans2 += a[i].ff.ff;
cnt++;
}
}
cout << max(ans1, ans2) << "\n";
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
//PUT("traffic.in", "traffic.out");
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
860 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
13 |
Incorrect |
10 ms |
2392 KB |
Output isn't correct |
14 |
Incorrect |
22 ms |
4956 KB |
Output isn't correct |
15 |
Runtime error |
52 ms |
17492 KB |
Execution killed with signal 6 |
16 |
Runtime error |
63 ms |
19620 KB |
Execution killed with signal 6 |
17 |
Runtime error |
89 ms |
23896 KB |
Execution killed with signal 6 |
18 |
Runtime error |
84 ms |
26188 KB |
Execution killed with signal 6 |
19 |
Runtime error |
89 ms |
28244 KB |
Execution killed with signal 6 |
20 |
Runtime error |
103 ms |
32596 KB |
Execution killed with signal 6 |