# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224619 | Nightlight | Lasers (NOI19_lasers) | C++14 | 192 ms | 10024 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pii pair<int, int>
#define l first
#define r second
using namespace std;
int L, N, M;
int pos[500005];
pii ran[500005];
int ans;
int main() {
// freopen("inp", "r", stdin);
scanf("%d %d", &L, &N);
int l, r, p = 0;
for(int i = 1; i <= N; i++) {
scanf("%d", &M);
for(int j = 1; j <= M; j++) {
scanf("%d", &pos[j]);
pos[j] += pos[j - 1];
}
for(int j = 1; j <= M; j++) {
l = L - (pos[M] - pos[j - 1]) + 1, r = pos[j];
if(l <= r) {
ran[++p] = {l, r};
}
}
}
sort(ran + 1, ran + p + 1);
int ln = 0, rn = -1;
for(int i = 1; i <= p; i++) {
if(ran[i].l > rn) {
ans += rn - ln + 1;
ln = ran[i].l;
rn = ran[i].r;
}else {
rn = max(ran[i].r, rn);
}
}
ans += rn - ln + 1;
printf("%d\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |