# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
391807 | 2021-04-20T01:13:19 Z | maomao90 | Lasers (NOI19_lasers) | C++14 | 440 ms | 67872 KB |
#include <bits/stdc++.h> using namespace std; #define mnto(x, y) x = min(x, (__typeof__(x)) y) #define mxto(x, y) x = max(x, (__typeof__(x)) y) #define REP(i, s, e) for (int i = s; i < e; i++) #define RREP(i, s, e) for (int i = s; i >= e; i--) typedef long long ll; typedef long double ld; #define MP make_pair #define FI first #define SE second typedef pair<int, int> ii; typedef pair<ll, ll> pll; #define MT make_tuple typedef tuple<int, int, int> iii; #define ALL(_a) _a.begin(), _a.end() #define pb emplace_back typedef vector<int> vi; typedef vector<ii> vii; #define INF 1000000005 #define LINF 1000000000000000005 #define MOD 1000000007 #define MAXR 500005 int l, r; int x[MAXR]; vi walls[MAXR]; vii ranges[MAXR], temp; int sum[MAXR]; priority_queue<ii, vector<ii>, greater<ii> > pq; int ans; vii joinRanges(vii arr) { vii res; if (arr.empty()) return res; int f = arr[0].FI, s = arr[0].SE; REP (i, 1, arr.size()) { if (s < arr[i].FI) { res.pb(f, s); f = arr[i].FI; s = arr[i].SE; } mxto(s, arr[i].SE); } res.pb(f, s); return res; } vii inv(vii arr) { vii res; int prv = 0; REP (i, 0, arr.size()) { if (prv < arr[i].FI) { res.pb(prv, arr[i].FI); } prv = arr[i].SE; } if (prv < l) { res.pb(prv, l); } return res; } int main() { scanf("%d%d", &l, &r); REP (i, 0, r) { scanf("%d", &x[i]); REP (j, 0, x[i]) { walls[i].pb(0); scanf("%d", &walls[i][j]); sum[i] += walls[i][j]; } } REP (i, 0, r) { int cur = 0; REP (j, 0, x[i] + 1) { if (cur < cur + l - sum[i]) { ranges[i].pb(cur, cur + l - sum[i]); // [l, r) } if (j != x[i]) cur += walls[i][j]; } ranges[i] = joinRanges(ranges[i]); ranges[i] = inv(ranges[i]); pq.push(MP(ranges[i].size(), i)); } while (pq.size() > 1) { int sze, i; tie(sze, i) = pq.top(); pq.pop(); int nsze, ni; tie(nsze, ni) = pq.top(); pq.pop(); temp.clear(); merge(ALL(ranges[i]), ALL(ranges[ni]), back_inserter<vii>(temp)); ranges[ni] = joinRanges(temp); pq.push(MP(ranges[ni].size(), ni)); } int id = pq.top().SE; REP (i, 0, ranges[id].size()) { ans += ranges[id][i].SE - ranges[id][i].FI; } printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23716 KB | Output is correct |
2 | Correct | 16 ms | 23784 KB | Output is correct |
3 | Correct | 16 ms | 23712 KB | Output is correct |
4 | Correct | 15 ms | 23764 KB | Output is correct |
5 | Correct | 15 ms | 23804 KB | Output is correct |
6 | Correct | 15 ms | 23756 KB | Output is correct |
7 | Correct | 16 ms | 23756 KB | Output is correct |
8 | Correct | 15 ms | 23756 KB | Output is correct |
9 | Correct | 16 ms | 23704 KB | Output is correct |
10 | Correct | 15 ms | 23756 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23716 KB | Output is correct |
2 | Correct | 16 ms | 23784 KB | Output is correct |
3 | Correct | 16 ms | 23712 KB | Output is correct |
4 | Correct | 15 ms | 23764 KB | Output is correct |
5 | Correct | 15 ms | 23804 KB | Output is correct |
6 | Correct | 15 ms | 23756 KB | Output is correct |
7 | Correct | 16 ms | 23756 KB | Output is correct |
8 | Correct | 15 ms | 23756 KB | Output is correct |
9 | Correct | 16 ms | 23704 KB | Output is correct |
10 | Correct | 15 ms | 23756 KB | Output is correct |
11 | Correct | 16 ms | 23864 KB | Output is correct |
12 | Correct | 364 ms | 67872 KB | Output is correct |
13 | Correct | 16 ms | 23756 KB | Output is correct |
14 | Correct | 17 ms | 23796 KB | Output is correct |
15 | Correct | 16 ms | 23756 KB | Output is correct |
16 | Correct | 16 ms | 23852 KB | Output is correct |
17 | Correct | 440 ms | 59452 KB | Output is correct |
18 | Correct | 16 ms | 23756 KB | Output is correct |
19 | Correct | 15 ms | 23764 KB | Output is correct |
20 | Correct | 14 ms | 23768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 31640 KB | Output is correct |
2 | Correct | 26 ms | 25628 KB | Output is correct |
3 | Correct | 27 ms | 25316 KB | Output is correct |
4 | Correct | 63 ms | 32532 KB | Output is correct |
5 | Correct | 39 ms | 28016 KB | Output is correct |
6 | Correct | 68 ms | 33472 KB | Output is correct |
7 | Correct | 17 ms | 23952 KB | Output is correct |
8 | Correct | 76 ms | 33464 KB | Output is correct |
9 | Correct | 41 ms | 29312 KB | Output is correct |
10 | Correct | 68 ms | 32472 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23756 KB | Output is correct |
2 | Correct | 12 ms | 23776 KB | Output is correct |
3 | Correct | 17 ms | 23788 KB | Output is correct |
4 | Correct | 16 ms | 23724 KB | Output is correct |
5 | Correct | 16 ms | 23692 KB | Output is correct |
6 | Correct | 16 ms | 23756 KB | Output is correct |
7 | Correct | 16 ms | 23776 KB | Output is correct |
8 | Correct | 16 ms | 23756 KB | Output is correct |
9 | Correct | 16 ms | 23780 KB | Output is correct |
10 | Correct | 16 ms | 23744 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 31640 KB | Output is correct |
2 | Correct | 26 ms | 25628 KB | Output is correct |
3 | Correct | 27 ms | 25316 KB | Output is correct |
4 | Correct | 63 ms | 32532 KB | Output is correct |
5 | Correct | 39 ms | 28016 KB | Output is correct |
6 | Correct | 68 ms | 33472 KB | Output is correct |
7 | Correct | 17 ms | 23952 KB | Output is correct |
8 | Correct | 76 ms | 33464 KB | Output is correct |
9 | Correct | 41 ms | 29312 KB | Output is correct |
10 | Correct | 68 ms | 32472 KB | Output is correct |
11 | Correct | 15 ms | 23756 KB | Output is correct |
12 | Correct | 12 ms | 23776 KB | Output is correct |
13 | Correct | 17 ms | 23788 KB | Output is correct |
14 | Correct | 16 ms | 23724 KB | Output is correct |
15 | Correct | 16 ms | 23692 KB | Output is correct |
16 | Correct | 16 ms | 23756 KB | Output is correct |
17 | Correct | 16 ms | 23776 KB | Output is correct |
18 | Correct | 16 ms | 23756 KB | Output is correct |
19 | Correct | 16 ms | 23780 KB | Output is correct |
20 | Correct | 16 ms | 23744 KB | Output is correct |
21 | Correct | 422 ms | 59148 KB | Output is correct |
22 | Correct | 36 ms | 25816 KB | Output is correct |
23 | Correct | 29 ms | 25548 KB | Output is correct |
24 | Correct | 77 ms | 30424 KB | Output is correct |
25 | Correct | 416 ms | 59136 KB | Output is correct |
26 | Correct | 56 ms | 27972 KB | Output is correct |
27 | Correct | 33 ms | 25436 KB | Output is correct |
28 | Correct | 412 ms | 59176 KB | Output is correct |
29 | Correct | 411 ms | 59212 KB | Output is correct |
30 | Correct | 62 ms | 28988 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23716 KB | Output is correct |
2 | Correct | 16 ms | 23784 KB | Output is correct |
3 | Correct | 16 ms | 23712 KB | Output is correct |
4 | Correct | 15 ms | 23764 KB | Output is correct |
5 | Correct | 15 ms | 23804 KB | Output is correct |
6 | Correct | 15 ms | 23756 KB | Output is correct |
7 | Correct | 16 ms | 23756 KB | Output is correct |
8 | Correct | 15 ms | 23756 KB | Output is correct |
9 | Correct | 16 ms | 23704 KB | Output is correct |
10 | Correct | 15 ms | 23756 KB | Output is correct |
11 | Correct | 16 ms | 23864 KB | Output is correct |
12 | Correct | 364 ms | 67872 KB | Output is correct |
13 | Correct | 16 ms | 23756 KB | Output is correct |
14 | Correct | 17 ms | 23796 KB | Output is correct |
15 | Correct | 16 ms | 23756 KB | Output is correct |
16 | Correct | 16 ms | 23852 KB | Output is correct |
17 | Correct | 440 ms | 59452 KB | Output is correct |
18 | Correct | 16 ms | 23756 KB | Output is correct |
19 | Correct | 15 ms | 23764 KB | Output is correct |
20 | Correct | 14 ms | 23768 KB | Output is correct |
21 | Correct | 63 ms | 31640 KB | Output is correct |
22 | Correct | 26 ms | 25628 KB | Output is correct |
23 | Correct | 27 ms | 25316 KB | Output is correct |
24 | Correct | 63 ms | 32532 KB | Output is correct |
25 | Correct | 39 ms | 28016 KB | Output is correct |
26 | Correct | 68 ms | 33472 KB | Output is correct |
27 | Correct | 17 ms | 23952 KB | Output is correct |
28 | Correct | 76 ms | 33464 KB | Output is correct |
29 | Correct | 41 ms | 29312 KB | Output is correct |
30 | Correct | 68 ms | 32472 KB | Output is correct |
31 | Correct | 15 ms | 23756 KB | Output is correct |
32 | Correct | 12 ms | 23776 KB | Output is correct |
33 | Correct | 17 ms | 23788 KB | Output is correct |
34 | Correct | 16 ms | 23724 KB | Output is correct |
35 | Correct | 16 ms | 23692 KB | Output is correct |
36 | Correct | 16 ms | 23756 KB | Output is correct |
37 | Correct | 16 ms | 23776 KB | Output is correct |
38 | Correct | 16 ms | 23756 KB | Output is correct |
39 | Correct | 16 ms | 23780 KB | Output is correct |
40 | Correct | 16 ms | 23744 KB | Output is correct |
41 | Correct | 422 ms | 59148 KB | Output is correct |
42 | Correct | 36 ms | 25816 KB | Output is correct |
43 | Correct | 29 ms | 25548 KB | Output is correct |
44 | Correct | 77 ms | 30424 KB | Output is correct |
45 | Correct | 416 ms | 59136 KB | Output is correct |
46 | Correct | 56 ms | 27972 KB | Output is correct |
47 | Correct | 33 ms | 25436 KB | Output is correct |
48 | Correct | 412 ms | 59176 KB | Output is correct |
49 | Correct | 411 ms | 59212 KB | Output is correct |
50 | Correct | 62 ms | 28988 KB | Output is correct |
51 | Correct | 34 ms | 26260 KB | Output is correct |
52 | Correct | 425 ms | 59900 KB | Output is correct |
53 | Correct | 418 ms | 59816 KB | Output is correct |
54 | Correct | 49 ms | 27204 KB | Output is correct |
55 | Correct | 93 ms | 31872 KB | Output is correct |
56 | Correct | 65 ms | 29088 KB | Output is correct |
57 | Correct | 66 ms | 29112 KB | Output is correct |
58 | Correct | 424 ms | 60652 KB | Output is correct |
59 | Correct | 52 ms | 27588 KB | Output is correct |
60 | Correct | 68 ms | 29312 KB | Output is correct |