# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
519429 |
2022-01-26T10:51:51 Z |
Jomnoi |
Lasers (NOI19_lasers) |
C++17 |
|
220 ms |
68500 KB |
#include <bits/stdc++.h>
#define DEBUG 0
using namespace std;
using pii = pair <int, int>;
const int N = 5e5+10;
vector <int> laser[N];
vector <int> qs[N];
int ct[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int l, r;
cin >> l >> r;
for(int i = 1; i <= r; i++) {
int x, y;
cin >> x;
while(x--) {
cin >> y;
laser[i].push_back(y);
}
qs[i].push_back(0);
for(int j = 0; j < laser[i].size(); j++) {
qs[i].push_back(qs[i].back()+laser[i][j]);
}
if(DEBUG) {
cout << "\nDebug : ";
for(auto v : qs[i]) {
cout << v << " ";
}
cout << endl << endl;
}
}
if(DEBUG) {
cout << endl;
}
vector <pii> vec;
for(int i = 1; i <= r; i++) {
for(int j = 0; j < laser[i].size(); j++) {
int left = qs[i][j];
int right = l-qs[i].back()+qs[i][j+1];
int range = right-left;
if(DEBUG) {
cout << "Debug : ";
cout << left << " " << right << " " << 2*laser[i][j]-range << " " << range-laser[i][j] << endl;
}
if(2*laser[i][j]-range > 0) {
vec.emplace_back(left+range-laser[i][j]+1, 1);
vec.emplace_back(right-range+laser[i][j]+1, -1);
}
}
if(DEBUG) {
cout << endl;
}
}
sort(vec.begin(), vec.end());
int ans = 0, sum = 0, left = -1;
for(auto v : vec) {
sum += v.second;
if(left == -1) {
left = v.first;
}
if(!sum) {
ans += v.first-left;
left = -1;
}
}
cout << ans;
return 0;
}
Compilation message
lasers.cpp: In function 'int main()':
lasers.cpp:24:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(int j = 0; j < laser[i].size(); j++) {
| ~~^~~~~~~~~~~~~~~~~
lasers.cpp:40:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(int j = 0; j < laser[i].size(); j++) {
| ~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
23776 KB |
Output is correct |
2 |
Correct |
15 ms |
23688 KB |
Output is correct |
3 |
Correct |
12 ms |
23808 KB |
Output is correct |
4 |
Correct |
12 ms |
23756 KB |
Output is correct |
5 |
Correct |
12 ms |
23756 KB |
Output is correct |
6 |
Correct |
12 ms |
23756 KB |
Output is correct |
7 |
Correct |
14 ms |
23848 KB |
Output is correct |
8 |
Correct |
12 ms |
23796 KB |
Output is correct |
9 |
Correct |
13 ms |
23812 KB |
Output is correct |
10 |
Correct |
12 ms |
23804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
23776 KB |
Output is correct |
2 |
Correct |
15 ms |
23688 KB |
Output is correct |
3 |
Correct |
12 ms |
23808 KB |
Output is correct |
4 |
Correct |
12 ms |
23756 KB |
Output is correct |
5 |
Correct |
12 ms |
23756 KB |
Output is correct |
6 |
Correct |
12 ms |
23756 KB |
Output is correct |
7 |
Correct |
14 ms |
23848 KB |
Output is correct |
8 |
Correct |
12 ms |
23796 KB |
Output is correct |
9 |
Correct |
13 ms |
23812 KB |
Output is correct |
10 |
Correct |
12 ms |
23804 KB |
Output is correct |
11 |
Correct |
12 ms |
23884 KB |
Output is correct |
12 |
Correct |
194 ms |
68500 KB |
Output is correct |
13 |
Correct |
12 ms |
23812 KB |
Output is correct |
14 |
Correct |
13 ms |
23804 KB |
Output is correct |
15 |
Correct |
12 ms |
23808 KB |
Output is correct |
16 |
Correct |
12 ms |
23812 KB |
Output is correct |
17 |
Correct |
220 ms |
64964 KB |
Output is correct |
18 |
Correct |
15 ms |
23756 KB |
Output is correct |
19 |
Correct |
13 ms |
23756 KB |
Output is correct |
20 |
Correct |
12 ms |
23756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
30608 KB |
Output is correct |
2 |
Correct |
18 ms |
25292 KB |
Output is correct |
3 |
Correct |
21 ms |
25096 KB |
Output is correct |
4 |
Correct |
64 ms |
30976 KB |
Output is correct |
5 |
Correct |
31 ms |
27448 KB |
Output is correct |
6 |
Correct |
42 ms |
29500 KB |
Output is correct |
7 |
Correct |
13 ms |
23872 KB |
Output is correct |
8 |
Correct |
45 ms |
30404 KB |
Output is correct |
9 |
Correct |
35 ms |
30016 KB |
Output is correct |
10 |
Correct |
66 ms |
31436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23756 KB |
Output is correct |
2 |
Correct |
12 ms |
23756 KB |
Output is correct |
3 |
Correct |
16 ms |
23760 KB |
Output is correct |
4 |
Correct |
12 ms |
23756 KB |
Output is correct |
5 |
Correct |
12 ms |
23756 KB |
Output is correct |
6 |
Correct |
11 ms |
23756 KB |
Output is correct |
7 |
Correct |
12 ms |
23884 KB |
Output is correct |
8 |
Correct |
12 ms |
23884 KB |
Output is correct |
9 |
Correct |
12 ms |
23808 KB |
Output is correct |
10 |
Correct |
12 ms |
23740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
30608 KB |
Output is correct |
2 |
Correct |
18 ms |
25292 KB |
Output is correct |
3 |
Correct |
21 ms |
25096 KB |
Output is correct |
4 |
Correct |
64 ms |
30976 KB |
Output is correct |
5 |
Correct |
31 ms |
27448 KB |
Output is correct |
6 |
Correct |
42 ms |
29500 KB |
Output is correct |
7 |
Correct |
13 ms |
23872 KB |
Output is correct |
8 |
Correct |
45 ms |
30404 KB |
Output is correct |
9 |
Correct |
35 ms |
30016 KB |
Output is correct |
10 |
Correct |
66 ms |
31436 KB |
Output is correct |
11 |
Correct |
14 ms |
23756 KB |
Output is correct |
12 |
Correct |
12 ms |
23756 KB |
Output is correct |
13 |
Correct |
16 ms |
23760 KB |
Output is correct |
14 |
Correct |
12 ms |
23756 KB |
Output is correct |
15 |
Correct |
12 ms |
23756 KB |
Output is correct |
16 |
Correct |
11 ms |
23756 KB |
Output is correct |
17 |
Correct |
12 ms |
23884 KB |
Output is correct |
18 |
Correct |
12 ms |
23884 KB |
Output is correct |
19 |
Correct |
12 ms |
23808 KB |
Output is correct |
20 |
Correct |
12 ms |
23740 KB |
Output is correct |
21 |
Correct |
185 ms |
63348 KB |
Output is correct |
22 |
Correct |
31 ms |
26988 KB |
Output is correct |
23 |
Correct |
24 ms |
26100 KB |
Output is correct |
24 |
Correct |
59 ms |
33396 KB |
Output is correct |
25 |
Correct |
200 ms |
63376 KB |
Output is correct |
26 |
Correct |
54 ms |
32240 KB |
Output is correct |
27 |
Correct |
29 ms |
26684 KB |
Output is correct |
28 |
Correct |
178 ms |
63232 KB |
Output is correct |
29 |
Correct |
187 ms |
63472 KB |
Output is correct |
30 |
Correct |
45 ms |
30108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
23776 KB |
Output is correct |
2 |
Correct |
15 ms |
23688 KB |
Output is correct |
3 |
Correct |
12 ms |
23808 KB |
Output is correct |
4 |
Correct |
12 ms |
23756 KB |
Output is correct |
5 |
Correct |
12 ms |
23756 KB |
Output is correct |
6 |
Correct |
12 ms |
23756 KB |
Output is correct |
7 |
Correct |
14 ms |
23848 KB |
Output is correct |
8 |
Correct |
12 ms |
23796 KB |
Output is correct |
9 |
Correct |
13 ms |
23812 KB |
Output is correct |
10 |
Correct |
12 ms |
23804 KB |
Output is correct |
11 |
Correct |
12 ms |
23884 KB |
Output is correct |
12 |
Correct |
194 ms |
68500 KB |
Output is correct |
13 |
Correct |
12 ms |
23812 KB |
Output is correct |
14 |
Correct |
13 ms |
23804 KB |
Output is correct |
15 |
Correct |
12 ms |
23808 KB |
Output is correct |
16 |
Correct |
12 ms |
23812 KB |
Output is correct |
17 |
Correct |
220 ms |
64964 KB |
Output is correct |
18 |
Correct |
15 ms |
23756 KB |
Output is correct |
19 |
Correct |
13 ms |
23756 KB |
Output is correct |
20 |
Correct |
12 ms |
23756 KB |
Output is correct |
21 |
Correct |
57 ms |
30608 KB |
Output is correct |
22 |
Correct |
18 ms |
25292 KB |
Output is correct |
23 |
Correct |
21 ms |
25096 KB |
Output is correct |
24 |
Correct |
64 ms |
30976 KB |
Output is correct |
25 |
Correct |
31 ms |
27448 KB |
Output is correct |
26 |
Correct |
42 ms |
29500 KB |
Output is correct |
27 |
Correct |
13 ms |
23872 KB |
Output is correct |
28 |
Correct |
45 ms |
30404 KB |
Output is correct |
29 |
Correct |
35 ms |
30016 KB |
Output is correct |
30 |
Correct |
66 ms |
31436 KB |
Output is correct |
31 |
Correct |
14 ms |
23756 KB |
Output is correct |
32 |
Correct |
12 ms |
23756 KB |
Output is correct |
33 |
Correct |
16 ms |
23760 KB |
Output is correct |
34 |
Correct |
12 ms |
23756 KB |
Output is correct |
35 |
Correct |
12 ms |
23756 KB |
Output is correct |
36 |
Correct |
11 ms |
23756 KB |
Output is correct |
37 |
Correct |
12 ms |
23884 KB |
Output is correct |
38 |
Correct |
12 ms |
23884 KB |
Output is correct |
39 |
Correct |
12 ms |
23808 KB |
Output is correct |
40 |
Correct |
12 ms |
23740 KB |
Output is correct |
41 |
Correct |
185 ms |
63348 KB |
Output is correct |
42 |
Correct |
31 ms |
26988 KB |
Output is correct |
43 |
Correct |
24 ms |
26100 KB |
Output is correct |
44 |
Correct |
59 ms |
33396 KB |
Output is correct |
45 |
Correct |
200 ms |
63376 KB |
Output is correct |
46 |
Correct |
54 ms |
32240 KB |
Output is correct |
47 |
Correct |
29 ms |
26684 KB |
Output is correct |
48 |
Correct |
178 ms |
63232 KB |
Output is correct |
49 |
Correct |
187 ms |
63472 KB |
Output is correct |
50 |
Correct |
45 ms |
30108 KB |
Output is correct |
51 |
Correct |
41 ms |
26684 KB |
Output is correct |
52 |
Correct |
188 ms |
64436 KB |
Output is correct |
53 |
Correct |
198 ms |
64476 KB |
Output is correct |
54 |
Correct |
43 ms |
29504 KB |
Output is correct |
55 |
Correct |
82 ms |
36408 KB |
Output is correct |
56 |
Correct |
61 ms |
32592 KB |
Output is correct |
57 |
Correct |
63 ms |
33464 KB |
Output is correct |
58 |
Correct |
199 ms |
64780 KB |
Output is correct |
59 |
Correct |
50 ms |
29792 KB |
Output is correct |
60 |
Correct |
63 ms |
31660 KB |
Output is correct |