#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int dp [N];
const int MAX_N = 1000000000 + 5;
const int ROOT = 0;
const int NODE = 1e7 + 5;
int L [NODE], R [NODE], Time = 0;
int seg [NODE];
short lazy [NODE];
int expandir (int delta) {
if (~delta) return delta;
return ++Time;
}
void push (int l, int r, int where) {
if (lazy[where] == 0) return;
const int mid = l + (r - l) / 2;
if (l != r) {
L[where] = expandir (L[where]);
R[where] = expandir (R[where]);
seg[L[where]] += lazy[where] * (mid - l + 1);
seg[R[where]] += lazy[where] * (r - (mid + 1) + 1);
lazy[L[where]] += lazy[where];
lazy[R[where]] += lazy[where];
}
lazy[where] = 0;
}
void modify (int l, int r, int where, int ql, int qr) {
if (l > qr || r < ql) return;
if (l >= ql && r <= qr) {
seg[where] += (r - l + 1);
++lazy[where];
return;
}
const int mid = l + (r - l) / 2;
push (l, r, where);
if (mid >= ql) {
L[where] = expandir (L[where]);
modify (l, mid, L[where], ql, qr);
}
if (mid + 1 <= qr) {
R[where] = expandir (R[where]);
modify (mid + 1, r, R[where], ql, qr);
}
seg[where] = (~L[where] ? seg[L[where]] : 0) + (~R[where] ? seg[R[where]] : 0);
}
int res = 0, goal;
void solve (int l, int r, int where) {
if (where == -1) {
res += (r - l + 1);
return;
}
if (l == r) {
res += (seg[where] != goal);
return;
}
const int mid = l + (r - l) / 2;
push (l, r, where);
solve (l, mid, L[where]);
solve (mid + 1, r, R[where]);
}
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
int l, r;
cin >> l >> r;
goal = r;
for (int i = 0; i < NODE; i++) {
L[i] = R[i] = -1;
seg[i] = 0;
lazy[i] = 0;
}
for (int T = 0; T < r; T++) {
int qts;
cin >> qts;
int s = 0;
vector<int> arr (qts);
for (int i = 0; i < qts; i++) {
cin >> arr[i];
s += arr[i];
}
int cur = 0;
int mn = 0;
int st, et;
for (int i = 0; i < qts; i++) {
st = max (mn, cur);
et = l - s - 1;
modify (0, l - 1, ROOT, st, et);
mn = max (mn, l - s);
cur += arr[i];
s -= arr[i];
}
st = max (mn, cur);
et = l - s - 1;
modify (0, l - 1, ROOT, st, et);
};
solve (0, l - 1, ROOT);
cout << res << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
290 ms |
262144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
290 ms |
262144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
173 ms |
138524 KB |
Output is correct |
2 |
Correct |
106 ms |
137720 KB |
Output is correct |
3 |
Correct |
118 ms |
137900 KB |
Output is correct |
4 |
Correct |
171 ms |
138368 KB |
Output is correct |
5 |
Correct |
132 ms |
138232 KB |
Output is correct |
6 |
Correct |
187 ms |
139000 KB |
Output is correct |
7 |
Correct |
92 ms |
137436 KB |
Output is correct |
8 |
Correct |
210 ms |
138820 KB |
Output is correct |
9 |
Correct |
144 ms |
138104 KB |
Output is correct |
10 |
Correct |
180 ms |
138420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
137312 KB |
Output is correct |
2 |
Correct |
79 ms |
137344 KB |
Output is correct |
3 |
Correct |
78 ms |
137336 KB |
Output is correct |
4 |
Correct |
79 ms |
137336 KB |
Output is correct |
5 |
Correct |
79 ms |
137336 KB |
Output is correct |
6 |
Correct |
92 ms |
137464 KB |
Output is correct |
7 |
Correct |
79 ms |
137464 KB |
Output is correct |
8 |
Correct |
80 ms |
137336 KB |
Output is correct |
9 |
Correct |
93 ms |
137336 KB |
Output is correct |
10 |
Correct |
79 ms |
137336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
173 ms |
138524 KB |
Output is correct |
2 |
Correct |
106 ms |
137720 KB |
Output is correct |
3 |
Correct |
118 ms |
137900 KB |
Output is correct |
4 |
Correct |
171 ms |
138368 KB |
Output is correct |
5 |
Correct |
132 ms |
138232 KB |
Output is correct |
6 |
Correct |
187 ms |
139000 KB |
Output is correct |
7 |
Correct |
92 ms |
137436 KB |
Output is correct |
8 |
Correct |
210 ms |
138820 KB |
Output is correct |
9 |
Correct |
144 ms |
138104 KB |
Output is correct |
10 |
Correct |
180 ms |
138420 KB |
Output is correct |
11 |
Correct |
81 ms |
137312 KB |
Output is correct |
12 |
Correct |
79 ms |
137344 KB |
Output is correct |
13 |
Correct |
78 ms |
137336 KB |
Output is correct |
14 |
Correct |
79 ms |
137336 KB |
Output is correct |
15 |
Correct |
79 ms |
137336 KB |
Output is correct |
16 |
Correct |
92 ms |
137464 KB |
Output is correct |
17 |
Correct |
79 ms |
137464 KB |
Output is correct |
18 |
Correct |
80 ms |
137336 KB |
Output is correct |
19 |
Correct |
93 ms |
137336 KB |
Output is correct |
20 |
Correct |
79 ms |
137336 KB |
Output is correct |
21 |
Incorrect |
751 ms |
137932 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
290 ms |
262144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |