# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
830306 |
2023-08-19T03:00:30 Z |
exodus_ |
Lasers (NOI19_lasers) |
C++14 |
|
256 ms |
9984 KB |
#include<bits/stdc++.h>
#define se second
#define fi first
using namespace std;
const int nmax = 5*1e5+5;
int lenwall[nmax];
vector<pair<int,int>>blck;
int main() {
int L,R,X;
int maxlen = 0;
cin >> L >> R;
for(int i=1; i<=R; i++) {
cin >> X;
int le=0;
int ri=L;
for(int j=1; j<=X; j++) {
cin >> lenwall[j];
le+=lenwall[j];
}
le-=lenwall[X];
for(int k=X; k>=1; k--) {
int l=le;
int r=le+lenwall[k];
int lt=ri-lenwall[k];
int rt=ri;
if(max(l,lt) < min(r,rt)) blck.push_back({max(l,lt), min(r,rt)});
if(k!=1) le-=lenwall[k-1];
ri-=lenwall[k];
}
}
sort(blck.begin(), blck.end());
int ans=0;
int right=0, left=0;
for(int i=0; i<blck.size(); i++) {
if(right<blck[i].fi) {
ans+=(right-left);
left = blck[i].fi;
right = blck[i].fi;
}
right = max(right, blck[i].se);
}
ans+=(right-left);
cout << ans << endl;
return 0;
}
Compilation message
lasers.cpp: In function 'int main()':
lasers.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int i=0; i<blck.size(); i++) {
| ~^~~~~~~~~~~~
lasers.cpp:10:9: warning: unused variable 'maxlen' [-Wunused-variable]
10 | int maxlen = 0;
| ^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
308 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
308 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
205 ms |
9984 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
211 ms |
7896 KB |
Output is correct |
18 |
Correct |
0 ms |
312 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
3672 KB |
Output is correct |
2 |
Correct |
10 ms |
1108 KB |
Output is correct |
3 |
Correct |
12 ms |
916 KB |
Output is correct |
4 |
Correct |
43 ms |
3724 KB |
Output is correct |
5 |
Correct |
31 ms |
2244 KB |
Output is correct |
6 |
Correct |
45 ms |
3080 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
64 ms |
2792 KB |
Output is correct |
9 |
Correct |
27 ms |
3192 KB |
Output is correct |
10 |
Correct |
50 ms |
3888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
224 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
312 KB |
Output is correct |
9 |
Correct |
1 ms |
308 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
3672 KB |
Output is correct |
2 |
Correct |
10 ms |
1108 KB |
Output is correct |
3 |
Correct |
12 ms |
916 KB |
Output is correct |
4 |
Correct |
43 ms |
3724 KB |
Output is correct |
5 |
Correct |
31 ms |
2244 KB |
Output is correct |
6 |
Correct |
45 ms |
3080 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
64 ms |
2792 KB |
Output is correct |
9 |
Correct |
27 ms |
3192 KB |
Output is correct |
10 |
Correct |
50 ms |
3888 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
224 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
308 KB |
Output is correct |
18 |
Correct |
1 ms |
312 KB |
Output is correct |
19 |
Correct |
1 ms |
308 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
194 ms |
6672 KB |
Output is correct |
22 |
Correct |
34 ms |
1504 KB |
Output is correct |
23 |
Correct |
16 ms |
1232 KB |
Output is correct |
24 |
Correct |
68 ms |
3788 KB |
Output is correct |
25 |
Correct |
201 ms |
6564 KB |
Output is correct |
26 |
Correct |
55 ms |
3680 KB |
Output is correct |
27 |
Correct |
25 ms |
1416 KB |
Output is correct |
28 |
Correct |
188 ms |
6584 KB |
Output is correct |
29 |
Correct |
189 ms |
6600 KB |
Output is correct |
30 |
Correct |
51 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
308 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
205 ms |
9984 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
211 ms |
7896 KB |
Output is correct |
18 |
Correct |
0 ms |
312 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
45 ms |
3672 KB |
Output is correct |
22 |
Correct |
10 ms |
1108 KB |
Output is correct |
23 |
Correct |
12 ms |
916 KB |
Output is correct |
24 |
Correct |
43 ms |
3724 KB |
Output is correct |
25 |
Correct |
31 ms |
2244 KB |
Output is correct |
26 |
Correct |
45 ms |
3080 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
64 ms |
2792 KB |
Output is correct |
29 |
Correct |
27 ms |
3192 KB |
Output is correct |
30 |
Correct |
50 ms |
3888 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
0 ms |
212 KB |
Output is correct |
33 |
Correct |
0 ms |
224 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
1 ms |
308 KB |
Output is correct |
38 |
Correct |
1 ms |
312 KB |
Output is correct |
39 |
Correct |
1 ms |
308 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
194 ms |
6672 KB |
Output is correct |
42 |
Correct |
34 ms |
1504 KB |
Output is correct |
43 |
Correct |
16 ms |
1232 KB |
Output is correct |
44 |
Correct |
68 ms |
3788 KB |
Output is correct |
45 |
Correct |
201 ms |
6564 KB |
Output is correct |
46 |
Correct |
55 ms |
3680 KB |
Output is correct |
47 |
Correct |
25 ms |
1416 KB |
Output is correct |
48 |
Correct |
188 ms |
6584 KB |
Output is correct |
49 |
Correct |
189 ms |
6600 KB |
Output is correct |
50 |
Correct |
51 ms |
2552 KB |
Output is correct |
51 |
Correct |
26 ms |
1632 KB |
Output is correct |
52 |
Correct |
210 ms |
7920 KB |
Output is correct |
53 |
Correct |
256 ms |
7832 KB |
Output is correct |
54 |
Correct |
49 ms |
2820 KB |
Output is correct |
55 |
Correct |
111 ms |
5196 KB |
Output is correct |
56 |
Correct |
63 ms |
4108 KB |
Output is correct |
57 |
Correct |
74 ms |
4452 KB |
Output is correct |
58 |
Correct |
216 ms |
7920 KB |
Output is correct |
59 |
Correct |
66 ms |
2600 KB |
Output is correct |
60 |
Correct |
87 ms |
3584 KB |
Output is correct |