제출 #1124937

#제출 시각아이디문제언어결과실행 시간메모리
1124937seiryuu학교 설립 (IZhO13_school)C++20
25 / 100
70 ms6080 KiB
#include <bits/stdc++.h> using namespace std; struct C { int a, b; long long d; }; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, m, s; cin >> n >> m >> s; vector<C> v(n); for (int i = 0; i < n; i++) { cin >> v[i].a >> v[i].b; v[i].d = (long long)v[i].a - v[i].b; } sort(v.begin(), v.end(), [&](const C &x, const C &y) { return x.d != y.d ? x.d > y.d : x.a > y.a; }); long long sa = 0, sb = 0; for (int i = 0; i < m; i++) sa += v[i].a; vector<int> r; for (int i = m; i < n; i++) r.push_back(v[i].b); if (s > 0) { if (s >= (int)r.size()) { for (auto x : r) sb += x; } else { nth_element(r.begin(), r.begin() + s, r.end(), greater<int>()); for (int i = 0; i < s; i++) sb += r[i]; } } cout << sa + sb; }
#Verdict Execution timeMemoryGrader output
Fetching results...