# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
90823 | 2018-12-24T15:58:52 Z | antimirage | 학교 설립 (IZhO13_school) | C++14 | 255 ms | 18816 KB |
#include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb emplace_back #define all(s) s.begin(), s.end() #define int long long using namespace std; const int N = 3e5 + 5; int n, x, y, a[N], b[N]; long long ans; priority_queue < int > q1; priority_queue < pair <int, int> > q2; set <int> st; main() { cin >> n >> x >> y; for (int i = 1; i <= n; i++) scanf("%d%d", &a[i], &b[i]); for (int i = 1; i <= x; i++) q1.push( -a[i] + b[i] ), ans += a[i]; for (int i = x + 1; i <= n; i++) { q2.push( mk( b[i], i ) ); st.insert(i); } while (y--) { while ( !q2.empty() && !st.count( q2.top().sc ) ) q2.pop(); if ( q2.empty() || q1.top() + a[ *st.begin() ] > q2.top().fr ) { ans += q1.top() + a[ *st.begin() ]; q1.pop(); q1.push( -a[ *st.begin() ] + b[ *st.begin() ] ); st.erase( st.begin() ); } else{ ans += q2.top().fr; st.erase( q2.top().sc ); q2.pop(); } } cout << ans << endl; } /** 3 1 1 5 2 4 1 6 4 **/
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 468 KB | Output is correct |
3 | Correct | 2 ms | 480 KB | Output is correct |
4 | Incorrect | 2 ms | 492 KB | Output isn't correct |
5 | Incorrect | 2 ms | 536 KB | Output isn't correct |
6 | Incorrect | 2 ms | 536 KB | Output isn't correct |
7 | Incorrect | 4 ms | 788 KB | Output isn't correct |
8 | Incorrect | 3 ms | 788 KB | Output isn't correct |
9 | Incorrect | 3 ms | 788 KB | Output isn't correct |
10 | Incorrect | 3 ms | 848 KB | Output isn't correct |
11 | Incorrect | 4 ms | 992 KB | Output isn't correct |
12 | Incorrect | 5 ms | 992 KB | Output isn't correct |
13 | Incorrect | 11 ms | 1756 KB | Output isn't correct |
14 | Incorrect | 50 ms | 6988 KB | Output isn't correct |
15 | Incorrect | 92 ms | 13432 KB | Output isn't correct |
16 | Incorrect | 255 ms | 13776 KB | Output isn't correct |
17 | Incorrect | 174 ms | 14924 KB | Output isn't correct |
18 | Incorrect | 170 ms | 15312 KB | Output isn't correct |
19 | Incorrect | 214 ms | 15852 KB | Output isn't correct |
20 | Incorrect | 255 ms | 18816 KB | Output isn't correct |