Submission #676481

# Submission time Handle Problem Language Result Execution time Memory
676481 2022-12-31T03:35:50 Z penguin133 Lasers (NOI19_lasers) C++17
100 / 100
458 ms 21392 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int X[500005], P[500005],S[500005];
map<int, int>m;

main(){
	int n,r;
	cin >> n >> r;
	int maxi = 0;
	while(r--){
		int a;
		cin >> a;
		maxi = max(maxi, a);
		vector<pair<int, int> >v;
		for(int i=1;i<=maxi;i++)X[i] = 0;
		for(int i=1;i<=a;i++){
			cin >> X[i];
			P[i] = P[i-1] + X[i];
		}
		int b = n;
		for(int i=a+1;i>=1;i--){
			b -= X[i];
			v.push_back(make_pair(P[i-1] + 1, b));
		}
		sort(v.begin(), v.end());
		for(int i=0;i<v.size()-1;i++){
			if(v[i].second + 1 < v[i+1].first)m[v[i].second+1]=max(m[v[i].second + 1], v[i+1].first-1);
		}
	}
	map<int, int> :: iterator it;
	it = m.begin();
	int cnt = 0;
	while(it != m.end()){
		int c = it->second, d = it->first;
		it++;
		while(it != m.end() && c >= it->first){
			c = max(c, it->second);
			it++;
		}
		cnt += (c-d)+1;
	}
	cout << cnt;
}

Compilation message

lasers.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~
lasers.cpp: In function 'int main()':
lasers.cpp:27:16: 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]
   27 |   for(int i=0;i<v.size()-1;i++){
      |               ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 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 0 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 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 0 ms 304 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 301 ms 6044 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 453 ms 19200 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
# Verdict Execution time Memory Grader output
1 Correct 102 ms 15880 KB Output is correct
2 Correct 20 ms 3800 KB Output is correct
3 Correct 26 ms 3072 KB Output is correct
4 Correct 103 ms 17684 KB Output is correct
5 Correct 41 ms 8744 KB Output is correct
6 Correct 78 ms 14752 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 100 ms 20820 KB Output is correct
9 Correct 70 ms 11428 KB Output is correct
10 Correct 119 ms 19924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 15880 KB Output is correct
2 Correct 20 ms 3800 KB Output is correct
3 Correct 26 ms 3072 KB Output is correct
4 Correct 103 ms 17684 KB Output is correct
5 Correct 41 ms 8744 KB Output is correct
6 Correct 78 ms 14752 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 100 ms 20820 KB Output is correct
9 Correct 70 ms 11428 KB Output is correct
10 Correct 119 ms 19924 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 400 ms 16588 KB Output is correct
22 Correct 52 ms 4712 KB Output is correct
23 Correct 28 ms 4132 KB Output is correct
24 Correct 124 ms 14056 KB Output is correct
25 Correct 404 ms 16460 KB Output is correct
26 Correct 121 ms 9192 KB Output is correct
27 Correct 44 ms 3916 KB Output is correct
28 Correct 398 ms 16456 KB Output is correct
29 Correct 427 ms 16436 KB Output is correct
30 Correct 91 ms 10848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 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 0 ms 304 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 301 ms 6044 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 453 ms 19200 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 102 ms 15880 KB Output is correct
22 Correct 20 ms 3800 KB Output is correct
23 Correct 26 ms 3072 KB Output is correct
24 Correct 103 ms 17684 KB Output is correct
25 Correct 41 ms 8744 KB Output is correct
26 Correct 78 ms 14752 KB Output is correct
27 Correct 2 ms 596 KB Output is correct
28 Correct 100 ms 20820 KB Output is correct
29 Correct 70 ms 11428 KB Output is correct
30 Correct 119 ms 19924 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 312 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 316 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 312 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 400 ms 16588 KB Output is correct
42 Correct 52 ms 4712 KB Output is correct
43 Correct 28 ms 4132 KB Output is correct
44 Correct 124 ms 14056 KB Output is correct
45 Correct 404 ms 16460 KB Output is correct
46 Correct 121 ms 9192 KB Output is correct
47 Correct 44 ms 3916 KB Output is correct
48 Correct 398 ms 16456 KB Output is correct
49 Correct 427 ms 16436 KB Output is correct
50 Correct 91 ms 10848 KB Output is correct
51 Correct 47 ms 5848 KB Output is correct
52 Correct 447 ms 20784 KB Output is correct
53 Correct 449 ms 20624 KB Output is correct
54 Correct 89 ms 6660 KB Output is correct
55 Correct 239 ms 15908 KB Output is correct
56 Correct 151 ms 13824 KB Output is correct
57 Correct 158 ms 11408 KB Output is correct
58 Correct 458 ms 21392 KB Output is correct
59 Correct 106 ms 8524 KB Output is correct
60 Correct 147 ms 10576 KB Output is correct