# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
725498 | vjudge1 | 학교 설립 (IZhO13_school) | C++17 | 105 ms | 5196 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define B begin()
#define rB rbegin()
#define E end()
#define rE rend()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define sts stable_sort
using namespace std;
const int MAXN = 1e6 + 4;
const int MOD = 1e9 + 7;
bool comp[MAXN];
ll res = 0;
//void f(vector<pair<int, int> > v, vector<pair<int, int> > b, int m, int s, int n){
// for(int i = 0 ; i < n; i++){
// if(comp[i])continue;
// if(m == 0){
// for(int j = i; j < n && s > 0; j++){
// if(comp[j])continue;
// res += b[j];
// s--;
// }
// return;
// }else if(s == 0){
// for(int j = i; j < n && m > 0; j++){
// if(comp[j])continue;
// res += v[j];
// m--;
// }
// return;
// }
// if(v[i].S == b[i].S){
// if(v[i].F >= b[i].F){
// res += v[i].F;
// m--;
// comp[v[i].S] = 1;
// for(int j = i + 1; j < n; j++){
// if(comp[j])continue;
// res += b[j].F;
// comp[b[j].S] = 1;
// break;
// }
// }else{
// res += b[i].F;
// s--;
// comp[b[i].S] = 1;
// for(int j = i + 1; j < n; j++){
// if(comp[j])continue;
// res += v[j].F;
// comp[v[j].S] = 1;
// break;
// }
// }
// }else{
// if(v[i].S >= b[i].F){
// res +=
// comp[v[i].S] = 1;
// m--;
// }
// }
// }
//}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n, M, S; cin >> n >> M >> S;
vector<pair<int, int> > v(n);
vector<pair<int, int> > b(n);
for(int i = 0; i < n; i++){
cin >> v[i].F; v[i].S = i;
cin >> b[i].F; b[i].S = i;
}
sort(v.rB, v.rE);
sort(b.rB, b.rE);
for(int i = 0; i < n; i++){
if(M == 0)break;
if(comp[v[i].S])continue;
res += v[i].F;
comp[v[i].S] = 1;
M--;
}
for(int i = 0; i < n; i++){
if(S == 0)break;
if(comp[b[i].S])continue;
res += b[i].F;
comp[b[i].S] = 1;
S--;
}
cout << res << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |