# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1114491 |
2024-11-19T05:46:23 Z |
Tsagana |
Schools (IZhO13_school) |
C++14 |
|
330 ms |
14752 KB |
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define lnl long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
#define sp << ' ' <<
#define nl << '\n'
using namespace std;
vector<pair<int, int>> vx;
vector<pair<int, int>> vy;
vector<pair<int, int>> v;
queue<int> q;
int has[300001];
bool cmp(pair<int, int> a, pair<int, int> b) {return (a.F < b.F ? 0 : 1);}
void solve () {
int n, m, s; cin >> n >> m >> s;
for (int i = 0; i < n; i++) {
int x, y; cin >> x >> y;
v.pb({x, y});
vx.pb({x, i});
vy.pb({y, i});
}
sort(all(vx), cmp);
sort(all(vy), cmp);
int ans = 0, lx = m, ly = s;
for(int i = 0; i < m; i++) {
ans += vx[i].F;
has[vx[i].S]++;
}
for(int i = 0; i < s; i++) {
ans += vy[i].F;
has[vy[i].S]++;
if (has[vy[i].S] == 2) q.push(vy[i].S);
}
while(!q.empty()) {
int i = q.front(); q.pop();
while (lx < n && has[vx[lx].S]) lx++;
while (ly < n && has[vy[ly].S]) ly++;
int d1 = v[i].F - vx[lx].F;
int d2 = v[i].S - vy[ly].F;
if (ly == n || d2 <= d1) {
ans -= d2;
has[vx[lx].S] = 1;
continue ;
}
if (lx == n || d1 <= d2) {
ans -= d1;
has[vy[ly].S] = 1;
continue ;
}
}
cout << ans;
}
int main() {IOS solve(); return 0;}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
508 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
592 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
592 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
592 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
592 KB |
Output isn't correct |
11 |
Incorrect |
3 ms |
592 KB |
Output isn't correct |
12 |
Incorrect |
3 ms |
592 KB |
Output isn't correct |
13 |
Incorrect |
14 ms |
1488 KB |
Output isn't correct |
14 |
Incorrect |
28 ms |
2744 KB |
Output isn't correct |
15 |
Incorrect |
53 ms |
7612 KB |
Output isn't correct |
16 |
Incorrect |
76 ms |
7600 KB |
Output isn't correct |
17 |
Incorrect |
203 ms |
7768 KB |
Output isn't correct |
18 |
Incorrect |
237 ms |
7600 KB |
Output isn't correct |
19 |
Incorrect |
269 ms |
7776 KB |
Output isn't correct |
20 |
Incorrect |
330 ms |
14752 KB |
Output isn't correct |