# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
725516 | 2023-04-17T14:43:07 Z | vjudge1 | Schools (IZhO13_school) | C++17 | 1 ms | 340 KB |
#include <bits/stdc++.h> #define F first #define S second using namespace std; using ll = long long; using PI = pair<int, int>; using PII = pair<PI, int>; int main() { freopen("school.in", "r", stdin); freopen("school.out", "w", stdout); //ios_base::sync_with_stdio(0); cin.tie(0); int n, m, s; cin >> n >> m >> s; vector<PII> vp(n+10); for(int i = 0; i < n; i++){ cin >> vp[i].F.F >> vp[i].F.S; vp[i].S = i; } vector<PII> ord; for(int i = 0; i < n; i++){ ord.push_back({{vp[i].F.F-vp[i].F.S, vp[i].F.F}, i}); } sort(ord.begin(), ord.end(), [&](PII a, PII b){ if(a.F.F != b.F.F){ return a.F.F > b.F.F; } return a.F.S > b.F.S; }); int ans = 0; int indx = 0; vector<bool> vis(n+10); while(m--){ ans += vp[ord[indx].S].F.F; vis[ord[indx].S] = true; indx++; } sort(vp.begin(), vp.end(), [&](PII a, PII b){ if(a.F.S != b.F.S){ return a.F.S > b.F.S; } return a.F.F > b.F.F; }); int cnt = 0; int i = 0; while(cnt != s && i != n-1){ if(!vis[vp[i].S]){ ans += vp[i].F.S; cnt++; } i++; } cout << ans <<"\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
2 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
3 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
4 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
5 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
6 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
7 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
8 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
9 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
10 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
11 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
12 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
13 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
14 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
15 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
16 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
17 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
18 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
19 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
20 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |