# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
391806 | 2021-04-20T00:45:27 Z | maomao90 | Lasers (NOI19_lasers) | C++14 | 66 ms | 32492 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; REP (i, 1, arr.size()) { if (arr[i - 1].SE < arr[i].FI) { res.pb(f, arr[i - 1].SE); f = arr[i].FI; } } res.pb(f, arr[arr.size() - 1].SE); 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) { 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23756 KB | Output is correct |
2 | Correct | 15 ms | 23756 KB | Output is correct |
3 | Correct | 15 ms | 23744 KB | Output is correct |
4 | Correct | 15 ms | 23800 KB | Output is correct |
5 | Correct | 15 ms | 23800 KB | Output is correct |
6 | Correct | 15 ms | 23808 KB | Output is correct |
7 | Correct | 16 ms | 23804 KB | Output is correct |
8 | Correct | 15 ms | 23756 KB | Output is correct |
9 | Correct | 16 ms | 23756 KB | Output is correct |
10 | Correct | 17 ms | 23800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23756 KB | Output is correct |
2 | Correct | 15 ms | 23756 KB | Output is correct |
3 | Correct | 15 ms | 23744 KB | Output is correct |
4 | Correct | 15 ms | 23800 KB | Output is correct |
5 | Correct | 15 ms | 23800 KB | Output is correct |
6 | Correct | 15 ms | 23808 KB | Output is correct |
7 | Correct | 16 ms | 23804 KB | Output is correct |
8 | Correct | 15 ms | 23756 KB | Output is correct |
9 | Correct | 16 ms | 23756 KB | Output is correct |
10 | Correct | 17 ms | 23800 KB | Output is correct |
11 | Incorrect | 17 ms | 23812 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 66 ms | 32492 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 17 ms | 23796 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 66 ms | 32492 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23756 KB | Output is correct |
2 | Correct | 15 ms | 23756 KB | Output is correct |
3 | Correct | 15 ms | 23744 KB | Output is correct |
4 | Correct | 15 ms | 23800 KB | Output is correct |
5 | Correct | 15 ms | 23800 KB | Output is correct |
6 | Correct | 15 ms | 23808 KB | Output is correct |
7 | Correct | 16 ms | 23804 KB | Output is correct |
8 | Correct | 15 ms | 23756 KB | Output is correct |
9 | Correct | 16 ms | 23756 KB | Output is correct |
10 | Correct | 17 ms | 23800 KB | Output is correct |
11 | Incorrect | 17 ms | 23812 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |