#include <bits/stdc++.h>
using namespace std;
int presum[500005], start[500005], close[500005];
int main() {
int l, r, x, w;
cin >> l >> r;
for (int i = 1; i <= r; i++) {
cin >> x;
for (int j = 1; j <= x; j++) {
cin >> w;
presum[j] = presum[j-1] + w;
}
int gap = l - presum[x];
for (int j = 1; j <= x; j++) {
if (presum[j-1] + gap + 1 <= presum[j]) {
start[presum[j-1] + gap + 1]++;
close[presum[j]]++;
}
}
}
// Line Sweep
int count = 0, save, ans = 0;
for (int i = 1; i <= l; i++) {
// cout << i << " " << start[i] << " " << close[i] << endl;
if (start[i] == 0 and close[i] == 0) continue;
if (count == 0) save = i;
count += start[i];
count -= close[i];
if (count == 0) {
ans += (i-save)+1;
}
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
5680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
5680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |