# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
787081 | 2023-07-18T19:20:56 Z | GusterGoose27 | 팀들 (IOI15_teams) | C++17 | 3286 ms | 364420 KB |
#include "teams.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; const int MAXN = 5e5+5; pii students[MAXN]; int n; class stree { public: int sum = 0; stree *l = nullptr; stree *r = nullptr; stree(int lp, int rp) { if (lp < rp) { int mid = (lp+rp)/2; l = new stree(lp, mid); r = new stree(mid+1, rp); } } stree(stree *prv) { sum = prv->sum+1; } stree(stree *l, stree *r) : l(l), r(r) { sum = l->sum + r->sum; } stree *upd(int p, int lp = 0, int rp = n-1) { if (lp > p || rp < p) return this; if (lp == rp) { return new stree(this); } int mid = (lp+rp)/2; return new stree(l->upd(p, lp, mid), r->upd(p, mid+1, rp)); } int query(int lv, int rv, int lp = 0, int rp = n-1) { if (lp > rv || rp < lv) return 0; if (lp >= lv && rp <= rv) return sum; int mid = (lp+rp)/2; return l->query(lv, rv, lp, mid)+r->query(lv, rv, mid+1, rp); } }; stree *trees[MAXN]; void init(int N, int A[], int B[]) { n = N; for (int i = 0; i < n; i++) { students[i] = pii(A[i]-1, B[i]-1); } sort(students, students+n); trees[0] = new stree(0, n-1); int j = 0; for (int i = 0; i < n; i++) { trees[i+1] = trees[i]; while (j < n && students[j].first == i) trees[i+1] = trees[i+1]->upd(students[j++].second); } } int sum(int x0, int x1, int y0, int y1) { return trees[x1+1]->query(y0, y1)-trees[x0]->query(y0, y1); } int can(int m, int k[]) { sort(k, k+m); vector<pii> vals; ll s = 0; for (int i = 0; i < m; i++) { s += k[i]; if (vals.empty() || vals.back().first != k[i]-1) { vals.push_back(pii(k[i]-1, 0)); } vals.back().second += k[i]; } if (s > n) return 0; assert(vals.size()*vals.size() <= 2*n); m = vals.size(); vals.push_back(pii(n, 0)); vector<int> sub(m, 0); // gap between this and next for (int i = 0; i < m; i++) { for (int j = i; j < m && vals[i].second > 0; j++) { int cur = min(vals[i].second, sum(0, vals[i].first, vals[j].first, vals[j+1].first-1)-sub[j]); sub[j] += cur; vals[i].second -= cur; } if (vals[i].second > 0) return 0; } return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 0 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 98 ms | 64264 KB | Output is correct |
2 | Correct | 94 ms | 64300 KB | Output is correct |
3 | Correct | 98 ms | 64256 KB | Output is correct |
4 | Correct | 94 ms | 64636 KB | Output is correct |
5 | Correct | 61 ms | 64204 KB | Output is correct |
6 | Correct | 60 ms | 64312 KB | Output is correct |
7 | Correct | 58 ms | 64300 KB | Output is correct |
8 | Correct | 59 ms | 64332 KB | Output is correct |
9 | Correct | 60 ms | 62364 KB | Output is correct |
10 | Correct | 54 ms | 62204 KB | Output is correct |
11 | Correct | 56 ms | 65204 KB | Output is correct |
12 | Correct | 55 ms | 62156 KB | Output is correct |
13 | Correct | 63 ms | 65124 KB | Output is correct |
14 | Correct | 65 ms | 62824 KB | Output is correct |
15 | Correct | 86 ms | 64256 KB | Output is correct |
16 | Correct | 84 ms | 64256 KB | Output is correct |
17 | Correct | 74 ms | 65172 KB | Output is correct |
18 | Correct | 84 ms | 65184 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 149 ms | 64700 KB | Output is correct |
2 | Correct | 154 ms | 64716 KB | Output is correct |
3 | Correct | 220 ms | 68048 KB | Output is correct |
4 | Correct | 98 ms | 65944 KB | Output is correct |
5 | Correct | 81 ms | 65776 KB | Output is correct |
6 | Correct | 84 ms | 65836 KB | Output is correct |
7 | Correct | 80 ms | 65748 KB | Output is correct |
8 | Correct | 83 ms | 65868 KB | Output is correct |
9 | Correct | 56 ms | 63048 KB | Output is correct |
10 | Correct | 57 ms | 63216 KB | Output is correct |
11 | Correct | 88 ms | 66496 KB | Output is correct |
12 | Correct | 1069 ms | 63628 KB | Output is correct |
13 | Correct | 267 ms | 66788 KB | Output is correct |
14 | Correct | 221 ms | 67180 KB | Output is correct |
15 | Correct | 115 ms | 65968 KB | Output is correct |
16 | Correct | 114 ms | 66012 KB | Output is correct |
17 | Correct | 92 ms | 66896 KB | Output is correct |
18 | Correct | 81 ms | 66828 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 935 ms | 357192 KB | Output is correct |
2 | Correct | 867 ms | 358048 KB | Output is correct |
3 | Correct | 1082 ms | 364420 KB | Output is correct |
4 | Correct | 717 ms | 358600 KB | Output is correct |
5 | Correct | 381 ms | 358588 KB | Output is correct |
6 | Correct | 376 ms | 358444 KB | Output is correct |
7 | Correct | 379 ms | 358456 KB | Output is correct |
8 | Correct | 373 ms | 358552 KB | Output is correct |
9 | Correct | 312 ms | 343424 KB | Output is correct |
10 | Correct | 303 ms | 359268 KB | Output is correct |
11 | Correct | 2145 ms | 359236 KB | Output is correct |
12 | Correct | 3286 ms | 359436 KB | Output is correct |
13 | Correct | 1004 ms | 359228 KB | Output is correct |
14 | Correct | 1093 ms | 359700 KB | Output is correct |
15 | Correct | 639 ms | 358932 KB | Output is correct |
16 | Correct | 629 ms | 359080 KB | Output is correct |
17 | Correct | 387 ms | 359340 KB | Output is correct |
18 | Correct | 375 ms | 359228 KB | Output is correct |