| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1114317 | Tsagana | 학교 설립 (IZhO13_school) | C++14 | 341 ms | 18076 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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
using namespace std;
vector<pair<int, int>> vx;
vector<pair<int, int>> vy;
vector<pair<int, int>> v;
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]++;
}
for (int i = 0; i < n; i++) {
while (has[vx[lx].S]) lx++;
while (has[vy[ly].S]) ly++;
if (has[i] == 2) {
if (v[i].F - vx[lx].F <= v[i].S - vy[ly].F) {
ans -= v[i].F - vx[lx].F;
has[lx]++;
}
else {
ans -= v[i].S - vy[ly].F;
has[ly]++;
}
}
}
cout << ans;
}
int main() {IOS solve(); return 0;}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
