# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
235501 | 2020-05-28T11:40:49 Z | golazcc83 | 학교 설립 (IZhO13_school) | C++14 | 158 ms | 18168 KB |
#include <iostream> #include <algorithm> #define MINF -1000000000000000000 using namespace std; typedef long long ll; const int MAXN = 300001; int N, M, S; struct student { ll num; int idx; bool operator < (const student &o) const { if(num != o.num) return num > o.num; return idx < o.idx; } } A[MAXN], B[MAXN]; ll An[MAXN], Bn[MAXN]; bool v[MAXN]; int main() { scanf("%d %d %d", &N, &M, &S); for(int i = 0; i < N; ++i) { scanf("%lld %lld", &An[i], &Bn[i]); A[i].num = An[i]; B[i].num = Bn[i]; A[i].idx = B[i].idx = i; } sort(A, A + N); sort(B, B + N); A[N].num = B[N].num = MINF; fill(v, v + N + 1, false); ll res = 0; int ia = 0, ib = 0; int ta = 0, tb = 0; while(ta != M || tb != S) { while(ta != M) { if(!v[A[ia].idx]) { res += A[ia].num; v[A[ia].idx] = true; ++ia; ++ta; continue; } ll nxtA = Bn[A[ia].idx] + A[ia + 1].num; ll nxtB = B[ib].num + A[ia].num; if(nxtA > nxtB) { ++ia; continue; } res += A[ia].num - Bn[A[ia].idx]; --tb; ++ta; ++ia; } while(tb != S) { if(!v[B[ib].idx]) { res += B[ib].num; v[B[ib].idx] = true; ++ib; ++tb; continue; } ll nxtA = An[B[ib].idx] + B[ib + 1].num; ll nxtB = A[ia].num + B[ib].num; if(nxtA > nxtB) { ++ib; continue; } res += B[ib].num - An[B[ib].idx]; --ta; ++tb; ++ib; } } printf("%lld\n", res); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 512 KB | Output isn't correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Incorrect | 5 ms | 384 KB | Output isn't correct |
4 | Incorrect | 5 ms | 384 KB | Output isn't correct |
5 | Incorrect | 5 ms | 384 KB | Output isn't correct |
6 | Incorrect | 5 ms | 384 KB | Output isn't correct |
7 | Incorrect | 6 ms | 640 KB | Output isn't correct |
8 | Incorrect | 7 ms | 640 KB | Output isn't correct |
9 | Incorrect | 6 ms | 640 KB | Output isn't correct |
10 | Incorrect | 7 ms | 640 KB | Output isn't correct |
11 | Incorrect | 7 ms | 640 KB | Output isn't correct |
12 | Incorrect | 6 ms | 640 KB | Output isn't correct |
13 | Incorrect | 21 ms | 2560 KB | Output isn't correct |
14 | Incorrect | 41 ms | 4984 KB | Output isn't correct |
15 | Incorrect | 81 ms | 9720 KB | Output isn't correct |
16 | Incorrect | 91 ms | 10872 KB | Output isn't correct |
17 | Incorrect | 111 ms | 13432 KB | Output isn't correct |
18 | Incorrect | 119 ms | 14712 KB | Output isn't correct |
19 | Incorrect | 133 ms | 15864 KB | Output isn't correct |
20 | Incorrect | 158 ms | 18168 KB | Output isn't correct |