# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
88949 | Lkvatashidze | 학교 설립 (IZhO13_school) | C++17 | 5 ms | 844 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
pair < ll, ll > a[300005];
pair < ll, ll > b[300005];
ll used[300005];
ll n, m, s;
ll ans, ans0;
int main() {
freopen ("school.in", "r", stdin);
freopen ("school.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> s;
for (ll k=1; k<=n; k++) {
ll x, y;
cin >> x >> y;
a[k].first=x;
a[k].second=k;
b[k].first=y;
b[k].second=k;
}
sort (a+1,a+1+n);
sort (b+1,b+1+n);
for (ll k=n; k>=n-m+1; k--) {
ans+=a[k].first;
used[a[k].second]=true;
}
reverse(b+1,b+1+n);
ll i=1; ll j=1;
while (i<=s && j<=n) {
if (used[b[j].second]) {
j++;
continue;
}
ans+=b[j].first;
used[b[j].second]=true;
j++; i++;
}
for (ll k=1; k<=n; k++)
used[k]=false;
sort (a+1,a+1+n);
sort (b+1,b+1+n);
for (ll k=n; k>=n-s+1; k--) {
ans0+=b[k].first;
used[b[k].second]=true;
}
reverse(a+1,a+1+n);
i=1; j=1;
while (i<=m && j<=n) {
if (used[a[j].second]) {
j++;
continue;
}
ans0+=a[j].first;
used[b[j].second]=true;
j++; i++;
}
cout << max(ans,ans0);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |