# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
830308 |
2023-08-19T03:01:06 Z |
vjudge1 |
Lasers (NOI19_lasers) |
C++17 |
|
213 ms |
4436 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 |
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 |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
197 ms |
4436 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 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 |
213 ms |
2480 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
3092 KB |
Output is correct |
2 |
Correct |
10 ms |
912 KB |
Output is correct |
3 |
Correct |
12 ms |
724 KB |
Output is correct |
4 |
Correct |
43 ms |
3132 KB |
Output is correct |
5 |
Correct |
20 ms |
1980 KB |
Output is correct |
6 |
Correct |
45 ms |
2256 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
53 ms |
1844 KB |
Output is correct |
9 |
Correct |
26 ms |
2792 KB |
Output is correct |
10 |
Correct |
48 ms |
3216 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 |
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 |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
3092 KB |
Output is correct |
2 |
Correct |
10 ms |
912 KB |
Output is correct |
3 |
Correct |
12 ms |
724 KB |
Output is correct |
4 |
Correct |
43 ms |
3132 KB |
Output is correct |
5 |
Correct |
20 ms |
1980 KB |
Output is correct |
6 |
Correct |
45 ms |
2256 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
53 ms |
1844 KB |
Output is correct |
9 |
Correct |
26 ms |
2792 KB |
Output is correct |
10 |
Correct |
48 ms |
3216 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 |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
183 ms |
2436 KB |
Output is correct |
22 |
Correct |
26 ms |
848 KB |
Output is correct |
23 |
Correct |
15 ms |
976 KB |
Output is correct |
24 |
Correct |
65 ms |
2792 KB |
Output is correct |
25 |
Correct |
179 ms |
2420 KB |
Output is correct |
26 |
Correct |
52 ms |
2476 KB |
Output is correct |
27 |
Correct |
22 ms |
848 KB |
Output is correct |
28 |
Correct |
181 ms |
2404 KB |
Output is correct |
29 |
Correct |
195 ms |
2516 KB |
Output is correct |
30 |
Correct |
47 ms |
1612 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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
197 ms |
4436 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 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 |
213 ms |
2480 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
44 ms |
3092 KB |
Output is correct |
22 |
Correct |
10 ms |
912 KB |
Output is correct |
23 |
Correct |
12 ms |
724 KB |
Output is correct |
24 |
Correct |
43 ms |
3132 KB |
Output is correct |
25 |
Correct |
20 ms |
1980 KB |
Output is correct |
26 |
Correct |
45 ms |
2256 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
53 ms |
1844 KB |
Output is correct |
29 |
Correct |
26 ms |
2792 KB |
Output is correct |
30 |
Correct |
48 ms |
3216 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 |
212 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
212 KB |
Output is correct |
36 |
Correct |
0 ms |
212 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
212 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
183 ms |
2436 KB |
Output is correct |
42 |
Correct |
26 ms |
848 KB |
Output is correct |
43 |
Correct |
15 ms |
976 KB |
Output is correct |
44 |
Correct |
65 ms |
2792 KB |
Output is correct |
45 |
Correct |
179 ms |
2420 KB |
Output is correct |
46 |
Correct |
52 ms |
2476 KB |
Output is correct |
47 |
Correct |
22 ms |
848 KB |
Output is correct |
48 |
Correct |
181 ms |
2404 KB |
Output is correct |
49 |
Correct |
195 ms |
2516 KB |
Output is correct |
50 |
Correct |
47 ms |
1612 KB |
Output is correct |
51 |
Correct |
25 ms |
1032 KB |
Output is correct |
52 |
Correct |
210 ms |
2384 KB |
Output is correct |
53 |
Correct |
201 ms |
2380 KB |
Output is correct |
54 |
Correct |
47 ms |
1348 KB |
Output is correct |
55 |
Correct |
113 ms |
2428 KB |
Output is correct |
56 |
Correct |
62 ms |
2780 KB |
Output is correct |
57 |
Correct |
72 ms |
2416 KB |
Output is correct |
58 |
Correct |
206 ms |
2356 KB |
Output is correct |
59 |
Correct |
52 ms |
1440 KB |
Output is correct |
60 |
Correct |
84 ms |
1592 KB |
Output is correct |