# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
295338 |
2020-09-09T15:40:04 Z |
beso123 |
Lasers (NOI19_lasers) |
C++14 |
|
761 ms |
49120 KB |
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
int L,n,pas,bal[1000005];
vector<int> g[1000005];
vector<pii> both(vector<pii> A,vector<pii> B){
vector<pii> AB;
AB.reserve(A.size()+B.size());
AB.insert(AB.end(),A.begin(),A.end());
AB.insert(AB.end(),B.begin(),B.end());
return AB;
}
main(){
cin>>L>>n;
for(int k=1;k<=n;k++){
int N;
cin>>N;
int sum=0;
g[k].push_back(0);
for(int i=1;i<=N;i++){
int b;
cin>>b;
sum+=b;
g[k].push_back(b);
}
bal[k]=L-sum;
}
vector<pii> v;
for(int k=1;k<=n;k++){
int sum=0;
int l=1,r=bal[k];
vector<pii> bad,newv;
for(int i=1;i<g[k].size();i++){
int pos=g[k][i];
sum+=g[k][i];
int l1=sum+1,r1=sum+bal[k];
if(l<=l1 && l1<=r)
r=max(r1,r);
else{
bad.push_back({r+1,l1-1});
l=l1;
r=r1;
}
}
v=both(v,bad);
if(v.size()){
sort(v.begin(),v.end());
int cl=v[0].x,cr=v[0].y;
v.push_back({INT_MAX,INT_MAX});
for(int k=0;k<v.size();k++){
if(cl<=v[k].x && v[k].x<=cr)
cr=max(v[k].y,cr);
else{
newv.push_back({cl,cr});
cl=v[k].x;
cr=v[k].y;
}
}
}
v.resize(0);
v=newv;
}
for(int k=0;k<v.size();k++){
if(v[k].x<=v[k].y)
pas+=(v[k].y-v[k].x+1);
}
cout<<pas;
return 0;
}
Compilation message
lasers.cpp:16:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
16 | main(){
| ^
lasers.cpp: In function 'int main()':
lasers.cpp:36:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int i=1;i<g[k].size();i++){
| ~^~~~~~~~~~~~
lasers.cpp:37:13: warning: unused variable 'pos' [-Wunused-variable]
37 | int pos=g[k][i];
| ^~~
lasers.cpp:53:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int k=0;k<v.size();k++){
| ~^~~~~~~~~
lasers.cpp:66:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | for(int k=0;k<v.size();k++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
23808 KB |
Output is correct |
2 |
Correct |
16 ms |
23808 KB |
Output is correct |
3 |
Correct |
16 ms |
23808 KB |
Output is correct |
4 |
Correct |
17 ms |
23808 KB |
Output is correct |
5 |
Correct |
17 ms |
23808 KB |
Output is correct |
6 |
Correct |
17 ms |
23808 KB |
Output is correct |
7 |
Correct |
17 ms |
23808 KB |
Output is correct |
8 |
Correct |
17 ms |
23808 KB |
Output is correct |
9 |
Correct |
16 ms |
23808 KB |
Output is correct |
10 |
Correct |
16 ms |
23808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
23808 KB |
Output is correct |
2 |
Correct |
16 ms |
23808 KB |
Output is correct |
3 |
Correct |
16 ms |
23808 KB |
Output is correct |
4 |
Correct |
17 ms |
23808 KB |
Output is correct |
5 |
Correct |
17 ms |
23808 KB |
Output is correct |
6 |
Correct |
17 ms |
23808 KB |
Output is correct |
7 |
Correct |
17 ms |
23808 KB |
Output is correct |
8 |
Correct |
17 ms |
23808 KB |
Output is correct |
9 |
Correct |
16 ms |
23808 KB |
Output is correct |
10 |
Correct |
16 ms |
23808 KB |
Output is correct |
11 |
Correct |
18 ms |
23808 KB |
Output is correct |
12 |
Correct |
761 ms |
49096 KB |
Output is correct |
13 |
Correct |
16 ms |
23808 KB |
Output is correct |
14 |
Correct |
17 ms |
23808 KB |
Output is correct |
15 |
Correct |
18 ms |
23808 KB |
Output is correct |
16 |
Correct |
20 ms |
23808 KB |
Output is correct |
17 |
Correct |
751 ms |
49016 KB |
Output is correct |
18 |
Correct |
16 ms |
23808 KB |
Output is correct |
19 |
Correct |
17 ms |
23808 KB |
Output is correct |
20 |
Correct |
16 ms |
23808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
145 ms |
38848 KB |
Output is correct |
2 |
Correct |
42 ms |
26220 KB |
Output is correct |
3 |
Correct |
47 ms |
25968 KB |
Output is correct |
4 |
Correct |
152 ms |
39312 KB |
Output is correct |
5 |
Correct |
71 ms |
30952 KB |
Output is correct |
6 |
Correct |
136 ms |
32348 KB |
Output is correct |
7 |
Correct |
19 ms |
24132 KB |
Output is correct |
8 |
Correct |
155 ms |
34904 KB |
Output is correct |
9 |
Correct |
85 ms |
34624 KB |
Output is correct |
10 |
Correct |
155 ms |
40128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
23808 KB |
Output is correct |
2 |
Correct |
16 ms |
23808 KB |
Output is correct |
3 |
Correct |
17 ms |
23808 KB |
Output is correct |
4 |
Correct |
17 ms |
23808 KB |
Output is correct |
5 |
Correct |
16 ms |
23808 KB |
Output is correct |
6 |
Correct |
17 ms |
23808 KB |
Output is correct |
7 |
Correct |
17 ms |
23820 KB |
Output is correct |
8 |
Correct |
17 ms |
23808 KB |
Output is correct |
9 |
Correct |
18 ms |
23808 KB |
Output is correct |
10 |
Correct |
18 ms |
23808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
145 ms |
38848 KB |
Output is correct |
2 |
Correct |
42 ms |
26220 KB |
Output is correct |
3 |
Correct |
47 ms |
25968 KB |
Output is correct |
4 |
Correct |
152 ms |
39312 KB |
Output is correct |
5 |
Correct |
71 ms |
30952 KB |
Output is correct |
6 |
Correct |
136 ms |
32348 KB |
Output is correct |
7 |
Correct |
19 ms |
24132 KB |
Output is correct |
8 |
Correct |
155 ms |
34904 KB |
Output is correct |
9 |
Correct |
85 ms |
34624 KB |
Output is correct |
10 |
Correct |
155 ms |
40128 KB |
Output is correct |
11 |
Correct |
17 ms |
23808 KB |
Output is correct |
12 |
Correct |
16 ms |
23808 KB |
Output is correct |
13 |
Correct |
17 ms |
23808 KB |
Output is correct |
14 |
Correct |
17 ms |
23808 KB |
Output is correct |
15 |
Correct |
16 ms |
23808 KB |
Output is correct |
16 |
Correct |
17 ms |
23808 KB |
Output is correct |
17 |
Correct |
17 ms |
23820 KB |
Output is correct |
18 |
Correct |
17 ms |
23808 KB |
Output is correct |
19 |
Correct |
18 ms |
23808 KB |
Output is correct |
20 |
Correct |
18 ms |
23808 KB |
Output is correct |
21 |
Correct |
655 ms |
47740 KB |
Output is correct |
22 |
Correct |
86 ms |
26104 KB |
Output is correct |
23 |
Correct |
57 ms |
26468 KB |
Output is correct |
24 |
Correct |
189 ms |
34464 KB |
Output is correct |
25 |
Correct |
664 ms |
47492 KB |
Output is correct |
26 |
Correct |
150 ms |
28152 KB |
Output is correct |
27 |
Correct |
72 ms |
25592 KB |
Output is correct |
28 |
Correct |
652 ms |
47564 KB |
Output is correct |
29 |
Correct |
643 ms |
47608 KB |
Output is correct |
30 |
Correct |
149 ms |
31184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
23808 KB |
Output is correct |
2 |
Correct |
16 ms |
23808 KB |
Output is correct |
3 |
Correct |
16 ms |
23808 KB |
Output is correct |
4 |
Correct |
17 ms |
23808 KB |
Output is correct |
5 |
Correct |
17 ms |
23808 KB |
Output is correct |
6 |
Correct |
17 ms |
23808 KB |
Output is correct |
7 |
Correct |
17 ms |
23808 KB |
Output is correct |
8 |
Correct |
17 ms |
23808 KB |
Output is correct |
9 |
Correct |
16 ms |
23808 KB |
Output is correct |
10 |
Correct |
16 ms |
23808 KB |
Output is correct |
11 |
Correct |
18 ms |
23808 KB |
Output is correct |
12 |
Correct |
761 ms |
49096 KB |
Output is correct |
13 |
Correct |
16 ms |
23808 KB |
Output is correct |
14 |
Correct |
17 ms |
23808 KB |
Output is correct |
15 |
Correct |
18 ms |
23808 KB |
Output is correct |
16 |
Correct |
20 ms |
23808 KB |
Output is correct |
17 |
Correct |
751 ms |
49016 KB |
Output is correct |
18 |
Correct |
16 ms |
23808 KB |
Output is correct |
19 |
Correct |
17 ms |
23808 KB |
Output is correct |
20 |
Correct |
16 ms |
23808 KB |
Output is correct |
21 |
Correct |
145 ms |
38848 KB |
Output is correct |
22 |
Correct |
42 ms |
26220 KB |
Output is correct |
23 |
Correct |
47 ms |
25968 KB |
Output is correct |
24 |
Correct |
152 ms |
39312 KB |
Output is correct |
25 |
Correct |
71 ms |
30952 KB |
Output is correct |
26 |
Correct |
136 ms |
32348 KB |
Output is correct |
27 |
Correct |
19 ms |
24132 KB |
Output is correct |
28 |
Correct |
155 ms |
34904 KB |
Output is correct |
29 |
Correct |
85 ms |
34624 KB |
Output is correct |
30 |
Correct |
155 ms |
40128 KB |
Output is correct |
31 |
Correct |
17 ms |
23808 KB |
Output is correct |
32 |
Correct |
16 ms |
23808 KB |
Output is correct |
33 |
Correct |
17 ms |
23808 KB |
Output is correct |
34 |
Correct |
17 ms |
23808 KB |
Output is correct |
35 |
Correct |
16 ms |
23808 KB |
Output is correct |
36 |
Correct |
17 ms |
23808 KB |
Output is correct |
37 |
Correct |
17 ms |
23820 KB |
Output is correct |
38 |
Correct |
17 ms |
23808 KB |
Output is correct |
39 |
Correct |
18 ms |
23808 KB |
Output is correct |
40 |
Correct |
18 ms |
23808 KB |
Output is correct |
41 |
Correct |
655 ms |
47740 KB |
Output is correct |
42 |
Correct |
86 ms |
26104 KB |
Output is correct |
43 |
Correct |
57 ms |
26468 KB |
Output is correct |
44 |
Correct |
189 ms |
34464 KB |
Output is correct |
45 |
Correct |
664 ms |
47492 KB |
Output is correct |
46 |
Correct |
150 ms |
28152 KB |
Output is correct |
47 |
Correct |
72 ms |
25592 KB |
Output is correct |
48 |
Correct |
652 ms |
47564 KB |
Output is correct |
49 |
Correct |
643 ms |
47608 KB |
Output is correct |
50 |
Correct |
149 ms |
31184 KB |
Output is correct |
51 |
Correct |
98 ms |
27244 KB |
Output is correct |
52 |
Correct |
756 ms |
49120 KB |
Output is correct |
53 |
Correct |
735 ms |
48760 KB |
Output is correct |
54 |
Correct |
151 ms |
27512 KB |
Output is correct |
55 |
Correct |
325 ms |
32440 KB |
Output is correct |
56 |
Correct |
201 ms |
32040 KB |
Output is correct |
57 |
Correct |
215 ms |
29304 KB |
Output is correct |
58 |
Correct |
744 ms |
49016 KB |
Output is correct |
59 |
Correct |
157 ms |
27772 KB |
Output is correct |
60 |
Correct |
239 ms |
29688 KB |
Output is correct |