# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
674747 |
2022-12-26T06:21:18 Z |
QwertyPi |
Lasers (NOI19_lasers) |
C++14 |
|
391 ms |
54504 KB |
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;
int32_t main(){
int l, r; cin >> l >> r;
vector<pair<int, int>> block;
for(int i = 0; i < r; i++){
int k; cin >> k; int s = 0;
vector<int> a; vector<pair<int, int>> d;
for(int j = 0; j < k; j++){
int v; cin >> v; a.push_back(v);
}
auto add = [&d, &l] (int sl, int sr){
d.push_back({0, 1});
d.push_back({sl, -1});
d.push_back({l - sr, 1});
d.push_back({l, -1});
};
int sl = 0, sr = accumulate(a.begin(), a.end(), 0LL);
add(sl, sr);
for(auto i : a){
sl += i; sr -= i;
add(sl, sr);
}
sort(d.begin(), d.end());
int cnt = 0;
for(auto i : d){
cnt += i.se;
if(cnt == k && i.se == -1) block.push_back({i.fi, -1});
if(cnt == k + 1 && i.se == 1) block.push_back({i.fi, 1});
}
}
sort(block.begin(), block.end());
int ans = 0, cnt = 0, pv = -(1 << 30);
for(auto i : block){
if(cnt > 0) ans += i.fi - pv;
cnt += i.se;
pv = i.fi;
}
cout << ans << endl;
}
Compilation message
lasers.cpp: In function 'int32_t main()':
lasers.cpp:11:24: warning: unused variable 's' [-Wunused-variable]
11 | int k; cin >> k; int s = 0;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 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 |
304 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
379 ms |
17284 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 |
308 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
381 ms |
9588 KB |
Output is correct |
18 |
Correct |
0 ms |
296 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
144 ms |
32500 KB |
Output is correct |
2 |
Correct |
28 ms |
6448 KB |
Output is correct |
3 |
Correct |
37 ms |
7348 KB |
Output is correct |
4 |
Correct |
149 ms |
31588 KB |
Output is correct |
5 |
Correct |
73 ms |
20536 KB |
Output is correct |
6 |
Correct |
156 ms |
36668 KB |
Output is correct |
7 |
Correct |
3 ms |
976 KB |
Output is correct |
8 |
Correct |
188 ms |
54504 KB |
Output is correct |
9 |
Correct |
84 ms |
18968 KB |
Output is correct |
10 |
Correct |
154 ms |
35500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
296 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 |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
144 ms |
32500 KB |
Output is correct |
2 |
Correct |
28 ms |
6448 KB |
Output is correct |
3 |
Correct |
37 ms |
7348 KB |
Output is correct |
4 |
Correct |
149 ms |
31588 KB |
Output is correct |
5 |
Correct |
73 ms |
20536 KB |
Output is correct |
6 |
Correct |
156 ms |
36668 KB |
Output is correct |
7 |
Correct |
3 ms |
976 KB |
Output is correct |
8 |
Correct |
188 ms |
54504 KB |
Output is correct |
9 |
Correct |
84 ms |
18968 KB |
Output is correct |
10 |
Correct |
154 ms |
35500 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
300 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
296 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
304 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
357 ms |
12408 KB |
Output is correct |
22 |
Correct |
61 ms |
3032 KB |
Output is correct |
23 |
Correct |
40 ms |
7400 KB |
Output is correct |
24 |
Correct |
179 ms |
23352 KB |
Output is correct |
25 |
Correct |
345 ms |
12452 KB |
Output is correct |
26 |
Correct |
118 ms |
10080 KB |
Output is correct |
27 |
Correct |
49 ms |
2872 KB |
Output is correct |
28 |
Correct |
348 ms |
12448 KB |
Output is correct |
29 |
Correct |
354 ms |
12640 KB |
Output is correct |
30 |
Correct |
130 ms |
18836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
379 ms |
17284 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 |
308 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
381 ms |
9588 KB |
Output is correct |
18 |
Correct |
0 ms |
296 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
144 ms |
32500 KB |
Output is correct |
22 |
Correct |
28 ms |
6448 KB |
Output is correct |
23 |
Correct |
37 ms |
7348 KB |
Output is correct |
24 |
Correct |
149 ms |
31588 KB |
Output is correct |
25 |
Correct |
73 ms |
20536 KB |
Output is correct |
26 |
Correct |
156 ms |
36668 KB |
Output is correct |
27 |
Correct |
3 ms |
976 KB |
Output is correct |
28 |
Correct |
188 ms |
54504 KB |
Output is correct |
29 |
Correct |
84 ms |
18968 KB |
Output is correct |
30 |
Correct |
154 ms |
35500 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
300 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
296 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
1 ms |
304 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
340 KB |
Output is correct |
40 |
Correct |
1 ms |
340 KB |
Output is correct |
41 |
Correct |
357 ms |
12408 KB |
Output is correct |
42 |
Correct |
61 ms |
3032 KB |
Output is correct |
43 |
Correct |
40 ms |
7400 KB |
Output is correct |
44 |
Correct |
179 ms |
23352 KB |
Output is correct |
45 |
Correct |
345 ms |
12452 KB |
Output is correct |
46 |
Correct |
118 ms |
10080 KB |
Output is correct |
47 |
Correct |
49 ms |
2872 KB |
Output is correct |
48 |
Correct |
348 ms |
12448 KB |
Output is correct |
49 |
Correct |
354 ms |
12640 KB |
Output is correct |
50 |
Correct |
130 ms |
18836 KB |
Output is correct |
51 |
Correct |
59 ms |
7136 KB |
Output is correct |
52 |
Correct |
391 ms |
13604 KB |
Output is correct |
53 |
Correct |
381 ms |
13520 KB |
Output is correct |
54 |
Correct |
94 ms |
6244 KB |
Output is correct |
55 |
Correct |
227 ms |
11304 KB |
Output is correct |
56 |
Correct |
155 ms |
18044 KB |
Output is correct |
57 |
Correct |
151 ms |
10880 KB |
Output is correct |
58 |
Correct |
382 ms |
14040 KB |
Output is correct |
59 |
Correct |
111 ms |
5652 KB |
Output is correct |
60 |
Correct |
153 ms |
6960 KB |
Output is correct |