#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int l, r, curr[N], sum[N];
vector<int> s[2 * N];
multiset<int> S;
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> l >> r;
int ans = l;
for(int i = 0; i < r; i++) {
int x; cin >> x;
for(int j = 0; j < x; j++) {
int p; cin >> p;
sum[i] += p;
s[sum[i]].push_back(i);
}
S.insert(sum[i]);
}
for(int i = 1; i <= l; i++) {
if(l - i >= *S.rbegin()) ans--;
for(auto j : s[i]) {
S.erase(S.find(sum[j] - curr[j]));
curr[j] = i;
S.insert(sum[j] - curr[j]);
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
33 ms |
47948 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
33 ms |
47948 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
32388 KB |
Output is correct |
2 |
Correct |
42 ms |
25932 KB |
Output is correct |
3 |
Correct |
43 ms |
26540 KB |
Output is correct |
4 |
Correct |
74 ms |
32512 KB |
Output is correct |
5 |
Correct |
50 ms |
28172 KB |
Output is correct |
6 |
Correct |
86 ms |
35560 KB |
Output is correct |
7 |
Correct |
16 ms |
23920 KB |
Output is correct |
8 |
Correct |
96 ms |
36344 KB |
Output is correct |
9 |
Correct |
50 ms |
28596 KB |
Output is correct |
10 |
Correct |
73 ms |
33416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
23764 KB |
Output is correct |
2 |
Correct |
15 ms |
23884 KB |
Output is correct |
3 |
Correct |
13 ms |
23828 KB |
Output is correct |
4 |
Correct |
16 ms |
23708 KB |
Output is correct |
5 |
Correct |
15 ms |
23764 KB |
Output is correct |
6 |
Correct |
15 ms |
23764 KB |
Output is correct |
7 |
Correct |
13 ms |
23876 KB |
Output is correct |
8 |
Correct |
12 ms |
23836 KB |
Output is correct |
9 |
Correct |
16 ms |
23896 KB |
Output is correct |
10 |
Correct |
14 ms |
23796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
32388 KB |
Output is correct |
2 |
Correct |
42 ms |
25932 KB |
Output is correct |
3 |
Correct |
43 ms |
26540 KB |
Output is correct |
4 |
Correct |
74 ms |
32512 KB |
Output is correct |
5 |
Correct |
50 ms |
28172 KB |
Output is correct |
6 |
Correct |
86 ms |
35560 KB |
Output is correct |
7 |
Correct |
16 ms |
23920 KB |
Output is correct |
8 |
Correct |
96 ms |
36344 KB |
Output is correct |
9 |
Correct |
50 ms |
28596 KB |
Output is correct |
10 |
Correct |
73 ms |
33416 KB |
Output is correct |
11 |
Correct |
13 ms |
23764 KB |
Output is correct |
12 |
Correct |
15 ms |
23884 KB |
Output is correct |
13 |
Correct |
13 ms |
23828 KB |
Output is correct |
14 |
Correct |
16 ms |
23708 KB |
Output is correct |
15 |
Correct |
15 ms |
23764 KB |
Output is correct |
16 |
Correct |
15 ms |
23764 KB |
Output is correct |
17 |
Correct |
13 ms |
23876 KB |
Output is correct |
18 |
Correct |
12 ms |
23836 KB |
Output is correct |
19 |
Correct |
16 ms |
23896 KB |
Output is correct |
20 |
Correct |
14 ms |
23796 KB |
Output is correct |
21 |
Correct |
847 ms |
62824 KB |
Output is correct |
22 |
Correct |
82 ms |
28140 KB |
Output is correct |
23 |
Correct |
43 ms |
26948 KB |
Output is correct |
24 |
Correct |
139 ms |
36376 KB |
Output is correct |
25 |
Correct |
851 ms |
67028 KB |
Output is correct |
26 |
Correct |
158 ms |
32276 KB |
Output is correct |
27 |
Correct |
73 ms |
27500 KB |
Output is correct |
28 |
Correct |
848 ms |
66920 KB |
Output is correct |
29 |
Correct |
863 ms |
67140 KB |
Output is correct |
30 |
Correct |
119 ms |
33772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
33 ms |
47948 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |