# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1007684 |
2024-06-25T10:15:19 Z |
kebine |
Lasers (NOI19_lasers) |
C++17 |
|
78 ms |
11692 KB |
#include <bits/stdc++.h>
using namespace std;
# define int long long
# define fir first
# define sec second
# define pb push_back
# define endl "\n"
const int cnst = 2e5+5;
bool mutipletestcase = 0;
//bool debug = false;
bool sorting(pair<int, int> a, pair<int, int> b) {
return a.sec > b.sec;
}
void solve() {
int n, q; cin >> n >> q;
int ans = 0;
vector<pair<int, int>> range;
while(q--) {
// cerr << "IN" << endl;
int x; cin >> x;
int num[x+5];
int pre[x+5]; pre[0] = 0;
int suf[x+5]; suf[x+1] = n+1;
for(int i = 1; i<=x; i++) {
cin >> num[i];
pre[i] = pre[i-1]+num[i];
}
int prev = 0;
for(int i = x; i>=1; i--) suf[i] = suf[i+1]-num[i];
for(int i = 1; i<=x; i++) {
if(suf[i] <= pre[i]) range.pb({suf[i], pre[i]});
}
}
sort(range.begin(), range.end(), sorting);
int l = n+2; int r = n+1;
for(auto v: range) {
// cerr << v.fir << " " << v.sec << endl;
if(v.sec < l) {
ans += r-l+1;
r = v.sec;
}
l = min(l, v.fir);
}
ans += r-l+1;
cout << ans << endl;
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int t = 1;
if(mutipletestcase) cin >> t;
while(t--) solve();
}
Compilation message
lasers.cpp: In function 'void solve()':
lasers.cpp:35:13: warning: unused variable 'prev' [-Wunused-variable]
35 | int prev = 0;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
428 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
428 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
74 ms |
11692 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
77 ms |
8340 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
10128 KB |
Output is correct |
2 |
Correct |
6 ms |
2528 KB |
Output is correct |
3 |
Correct |
5 ms |
2272 KB |
Output is correct |
4 |
Correct |
28 ms |
9428 KB |
Output is correct |
5 |
Correct |
13 ms |
5848 KB |
Output is correct |
6 |
Correct |
21 ms |
10124 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
25 ms |
8408 KB |
Output is correct |
9 |
Correct |
21 ms |
9172 KB |
Output is correct |
10 |
Correct |
44 ms |
10452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
10128 KB |
Output is correct |
2 |
Correct |
6 ms |
2528 KB |
Output is correct |
3 |
Correct |
5 ms |
2272 KB |
Output is correct |
4 |
Correct |
28 ms |
9428 KB |
Output is correct |
5 |
Correct |
13 ms |
5848 KB |
Output is correct |
6 |
Correct |
21 ms |
10124 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
25 ms |
8408 KB |
Output is correct |
9 |
Correct |
21 ms |
9172 KB |
Output is correct |
10 |
Correct |
44 ms |
10452 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
452 KB |
Output is correct |
21 |
Correct |
73 ms |
7240 KB |
Output is correct |
22 |
Correct |
13 ms |
2012 KB |
Output is correct |
23 |
Correct |
8 ms |
2456 KB |
Output is correct |
24 |
Correct |
34 ms |
9172 KB |
Output is correct |
25 |
Correct |
76 ms |
7452 KB |
Output is correct |
26 |
Correct |
26 ms |
5588 KB |
Output is correct |
27 |
Correct |
10 ms |
2012 KB |
Output is correct |
28 |
Correct |
78 ms |
6796 KB |
Output is correct |
29 |
Correct |
74 ms |
7620 KB |
Output is correct |
30 |
Correct |
24 ms |
4816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
428 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
74 ms |
11692 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
77 ms |
8340 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
32 ms |
10128 KB |
Output is correct |
22 |
Correct |
6 ms |
2528 KB |
Output is correct |
23 |
Correct |
5 ms |
2272 KB |
Output is correct |
24 |
Correct |
28 ms |
9428 KB |
Output is correct |
25 |
Correct |
13 ms |
5848 KB |
Output is correct |
26 |
Correct |
21 ms |
10124 KB |
Output is correct |
27 |
Correct |
1 ms |
604 KB |
Output is correct |
28 |
Correct |
25 ms |
8408 KB |
Output is correct |
29 |
Correct |
21 ms |
9172 KB |
Output is correct |
30 |
Correct |
44 ms |
10452 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
604 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
0 ms |
348 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
0 ms |
452 KB |
Output is correct |
41 |
Correct |
73 ms |
7240 KB |
Output is correct |
42 |
Correct |
13 ms |
2012 KB |
Output is correct |
43 |
Correct |
8 ms |
2456 KB |
Output is correct |
44 |
Correct |
34 ms |
9172 KB |
Output is correct |
45 |
Correct |
76 ms |
7452 KB |
Output is correct |
46 |
Correct |
26 ms |
5588 KB |
Output is correct |
47 |
Correct |
10 ms |
2012 KB |
Output is correct |
48 |
Correct |
78 ms |
6796 KB |
Output is correct |
49 |
Correct |
74 ms |
7620 KB |
Output is correct |
50 |
Correct |
24 ms |
4816 KB |
Output is correct |
51 |
Correct |
12 ms |
2524 KB |
Output is correct |
52 |
Correct |
76 ms |
7924 KB |
Output is correct |
53 |
Correct |
78 ms |
8432 KB |
Output is correct |
54 |
Correct |
19 ms |
3544 KB |
Output is correct |
55 |
Correct |
50 ms |
7912 KB |
Output is correct |
56 |
Correct |
30 ms |
9172 KB |
Output is correct |
57 |
Correct |
33 ms |
7696 KB |
Output is correct |
58 |
Correct |
73 ms |
7364 KB |
Output is correct |
59 |
Correct |
23 ms |
3288 KB |
Output is correct |
60 |
Correct |
31 ms |
3788 KB |
Output is correct |