Submission #369268

# Submission time Handle Problem Language Result Execution time Memory
369268 2021-02-21T05:24:04 Z Berted Lasers (NOI19_lasers) C++17
100 / 100
579 ms 10204 KB
#include <iostream>
#include <algorithm>
#include <vector>
#define pii pair<int,int>
#define fst first
#define snd second
using namespace std;
int k,n,x,dt[500001]={};
vector<pii> v;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>k>>n;
	for (int i=0;i<n;i++)
	{
		int l = 0,r = k;
		cin>>x;
		for (int j=0;j<x;j++)
		{
			cin>>dt[j];l+=dt[j];
		}
		l-=dt[x-1];
		for (int j=x-1;j>=0;j--)
		{
			int l1 = l,r1 = l+dt[j],r2 = r,l2 = r-dt[j];
			//cout<<l1<<" "<<r1<<" "<<l2<<" "<<r2<<"\n";
			if (max(l1,l2)<min(r1,r2)) 
			{
				v.push_back({max(l1,l2),min(r1,r2)});
			}
			if (j) {l-=dt[j-1];}
			r-=dt[j];
		}
	}
	sort(v.begin(),v.end());
	int rs = 0,l = -1,r = -1;
	for (int i=0;i<v.size();i++)
	{
		if (r<v[i].fst) {rs += r-l;l = v[i].fst;r = v[i].fst;}
		r = max(r,v[i].snd);
	}
	rs += r-l;
	cout<<rs<<"\n";
	return 0;
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:37:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for (int i=0;i<v.size();i++)
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 34 ms 492 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 35 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 32 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 34 ms 492 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 35 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 32 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 110 ms 10204 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 114 ms 8112 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 3816 KB Output is correct
2 Correct 8 ms 1136 KB Output is correct
3 Correct 8 ms 1004 KB Output is correct
4 Correct 33 ms 3944 KB Output is correct
5 Correct 15 ms 2412 KB Output is correct
6 Correct 29 ms 3184 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 37 ms 2924 KB Output is correct
9 Correct 22 ms 3304 KB Output is correct
10 Correct 41 ms 4072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 32 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 3816 KB Output is correct
2 Correct 8 ms 1136 KB Output is correct
3 Correct 8 ms 1004 KB Output is correct
4 Correct 33 ms 3944 KB Output is correct
5 Correct 15 ms 2412 KB Output is correct
6 Correct 29 ms 3184 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 37 ms 2924 KB Output is correct
9 Correct 22 ms 3304 KB Output is correct
10 Correct 41 ms 4072 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 32 ms 364 KB Output is correct
21 Correct 579 ms 6620 KB Output is correct
22 Correct 18 ms 1644 KB Output is correct
23 Correct 13 ms 1364 KB Output is correct
24 Correct 49 ms 4020 KB Output is correct
25 Correct 110 ms 6756 KB Output is correct
26 Correct 38 ms 3816 KB Output is correct
27 Correct 15 ms 1520 KB Output is correct
28 Correct 109 ms 6756 KB Output is correct
29 Correct 110 ms 6756 KB Output is correct
30 Correct 33 ms 2664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 34 ms 492 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 35 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 32 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 110 ms 10204 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 114 ms 8112 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 35 ms 3816 KB Output is correct
22 Correct 8 ms 1136 KB Output is correct
23 Correct 8 ms 1004 KB Output is correct
24 Correct 33 ms 3944 KB Output is correct
25 Correct 15 ms 2412 KB Output is correct
26 Correct 29 ms 3184 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 37 ms 2924 KB Output is correct
29 Correct 22 ms 3304 KB Output is correct
30 Correct 41 ms 4072 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 1 ms 364 KB Output is correct
40 Correct 32 ms 364 KB Output is correct
41 Correct 579 ms 6620 KB Output is correct
42 Correct 18 ms 1644 KB Output is correct
43 Correct 13 ms 1364 KB Output is correct
44 Correct 49 ms 4020 KB Output is correct
45 Correct 110 ms 6756 KB Output is correct
46 Correct 38 ms 3816 KB Output is correct
47 Correct 15 ms 1520 KB Output is correct
48 Correct 109 ms 6756 KB Output is correct
49 Correct 110 ms 6756 KB Output is correct
50 Correct 33 ms 2664 KB Output is correct
51 Correct 16 ms 1772 KB Output is correct
52 Correct 116 ms 8048 KB Output is correct
53 Correct 119 ms 7824 KB Output is correct
54 Correct 28 ms 2924 KB Output is correct
55 Correct 66 ms 5504 KB Output is correct
56 Correct 40 ms 4328 KB Output is correct
57 Correct 45 ms 4712 KB Output is correct
58 Correct 121 ms 8036 KB Output is correct
59 Correct 32 ms 2792 KB Output is correct
60 Correct 44 ms 3816 KB Output is correct