# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
167110 | 2019-12-06T03:26:45 Z | abil | 학교 설립 (IZhO13_school) | C++14 | 280 ms | 11640 KB |
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (3e5 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); pair<int,pair<int,int > > a[N]; multiset<int > st; int pr[N], sf[N]; main() { int n, m, s, sum = 0; scanf("%d%d%d", &n, &m, &s); for(int i = 1;i <= n; i++){ scanf("%d%d", &a[i].sc.fr, &a[i].sc.sc); a[i].fr = a[i].sc.sc - a[i].sc.fr; } sort(a + 1,a + 1 + n); for(int i = 1;i <= n; i++){ sum += a[i].sc.fr; st.insert(a[i].sc.fr); if(i > m){ sum -= *st.begin(); st.erase(st.begin()); } pr[i] = sum; } st.clear(); sum = 0; for(int i = n;i >= 1; i--){ sum += a[i].sc.sc; st.insert(a[i].sc.sc); if(i <= n - s){ sum -= *st.begin(); st.erase(st.begin()); } sf[i] = sum; } int ans = 0; for(int i = max(1, m);i <= n - s; i++){ ans = max(ans, pr[i] + sf[i + 1]); } cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 4 ms | 504 KB | Output is correct |
8 | Correct | 5 ms | 632 KB | Output is correct |
9 | Correct | 5 ms | 632 KB | Output is correct |
10 | Correct | 5 ms | 632 KB | Output is correct |
11 | Correct | 5 ms | 636 KB | Output is correct |
12 | Correct | 5 ms | 632 KB | Output is correct |
13 | Correct | 30 ms | 2552 KB | Output is correct |
14 | Correct | 52 ms | 2808 KB | Output is correct |
15 | Correct | 78 ms | 3704 KB | Output is correct |
16 | Incorrect | 180 ms | 11300 KB | Output isn't correct |
17 | Incorrect | 217 ms | 9780 KB | Output isn't correct |
18 | Incorrect | 214 ms | 9328 KB | Output isn't correct |
19 | Incorrect | 241 ms | 10360 KB | Output isn't correct |
20 | Incorrect | 280 ms | 11640 KB | Output isn't correct |