제출 #1124943

#제출 시각아이디문제언어결과실행 시간메모리
1124943seiryuu학교 설립 (IZhO13_school)C++20
25 / 100
80 ms3912 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M, S; cin >> N >> M >> S; vector<pair<int,int>> cities(N); for (int i = 0; i < N; i++) { cin >> cities[i].first >> cities[i].second; // A_i, B_i } vector<int> idx(N); iota(idx.begin(), idx.end(), 0); sort(idx.begin(), idx.end(), [&](int a, int b) { return max(cities[a].first, cities[a].second) > max(cities[b].first, cities[b].second); }); idx.resize(M+S); sort(idx.begin(), idx.end(), [&](int a, int b) { return (cities[a].first - cities[a].second) > (cities[b].first - cities[b].second); }); long long answer = 0; for (int i = 0; i < M; i++) { answer += cities[idx[i]].first; } for (int i = M; i < M+S; i++) { answer += cities[idx[i]].second; } cout << answer << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...