Submission #224507

# Submission time Handle Problem Language Result Execution time Memory
224507 2020-04-18T09:15:50 Z maximath_1 Lasers (NOI19_lasers) C++17
100 / 100
110 ms 10076 KB
#include<bits/stdc++.h>
using namespace std;
#define gc getchar
#define pc putchar
int in(){
	char c=gc();
	for(; c<'0'||'9'<c; c=gc());
	int rs=c-'0'; c=gc();
	for(; '0'<=c && c<='9'; c=gc())
		rs=(rs<<1)+(rs<<3)+(c-'0');
	return rs;
}
void out(int _n){
	int N=_n, rev, count=0;
	rev=N;
	if(N==0) {pc('0'); return;}
	while((rev%10)==0) {count++; rev/=10;}
	rev=0;
	while(N!=0) {rev=(rev<<3)+(rev<<1)+N%10; N/=10;}
	while(rev!=0) {pc(rev%10+'0'); rev/=10;}
	while(count--) pc('0');
}
vector<pair<int, int> >ansv;
vector<int>v;
int len, n;
int main(){
	len=in(), n=in();
	for(int tc=0; tc<n; tc++){
		int x=in();
		v.resize(x+1); v[0]=0;
		for(int i=1; i<=x; i++)
			v[i]=in()+v[i-1];
		for(int i=1; i<=x; i++){
			int lf=len-(v[x]-v[i-1])+1, rg=v[i];
			if(lf<=rg) ansv.emplace_back(lf, rg);
		}
	}
	sort(ansv.begin(), ansv.end());
	if(ansv.size()==0){pc('0'); pc('\n'); return 0;}
	int lf=ansv[0].first, rg=ansv[0].second, ans=0;
	for(int i=1; i<ansv.size(); i++){
		int ln=ansv[i].first, rn=ansv[i].second;
		if(rg+1<ln){
			ans+=rg-lf+1;
			lf=ln; rg=rn;
		}else rg=max(rg, rn);
	}
	ans+=rg-lf+1;
	out(ans); pc('\n'); return 0;
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:41:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1; i<ansv.size(); i++){
               ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 96 ms 10076 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 103 ms 7908 KB Output is correct
18 Correct 5 ms 416 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 3828 KB Output is correct
2 Correct 9 ms 1152 KB Output is correct
3 Correct 10 ms 1024 KB Output is correct
4 Correct 35 ms 3836 KB Output is correct
5 Correct 17 ms 2380 KB Output is correct
6 Correct 21 ms 3068 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 23 ms 3320 KB Output is correct
9 Correct 18 ms 3316 KB Output is correct
10 Correct 34 ms 4016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 3828 KB Output is correct
2 Correct 9 ms 1152 KB Output is correct
3 Correct 10 ms 1024 KB Output is correct
4 Correct 35 ms 3836 KB Output is correct
5 Correct 17 ms 2380 KB Output is correct
6 Correct 21 ms 3068 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 23 ms 3320 KB Output is correct
9 Correct 18 ms 3316 KB Output is correct
10 Correct 34 ms 4016 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 4 ms 256 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 93 ms 7032 KB Output is correct
22 Correct 18 ms 1532 KB Output is correct
23 Correct 12 ms 1404 KB Output is correct
24 Correct 34 ms 3864 KB Output is correct
25 Correct 93 ms 6756 KB Output is correct
26 Correct 33 ms 3700 KB Output is correct
27 Correct 16 ms 1532 KB Output is correct
28 Correct 91 ms 6756 KB Output is correct
29 Correct 92 ms 6732 KB Output is correct
30 Correct 26 ms 2480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 96 ms 10076 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 103 ms 7908 KB Output is correct
18 Correct 5 ms 416 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 30 ms 3828 KB Output is correct
22 Correct 9 ms 1152 KB Output is correct
23 Correct 10 ms 1024 KB Output is correct
24 Correct 35 ms 3836 KB Output is correct
25 Correct 17 ms 2380 KB Output is correct
26 Correct 21 ms 3068 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 23 ms 3320 KB Output is correct
29 Correct 18 ms 3316 KB Output is correct
30 Correct 34 ms 4016 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 4 ms 256 KB Output is correct
33 Correct 4 ms 256 KB Output is correct
34 Correct 4 ms 256 KB Output is correct
35 Correct 5 ms 256 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 4 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 4 ms 384 KB Output is correct
41 Correct 93 ms 7032 KB Output is correct
42 Correct 18 ms 1532 KB Output is correct
43 Correct 12 ms 1404 KB Output is correct
44 Correct 34 ms 3864 KB Output is correct
45 Correct 93 ms 6756 KB Output is correct
46 Correct 33 ms 3700 KB Output is correct
47 Correct 16 ms 1532 KB Output is correct
48 Correct 91 ms 6756 KB Output is correct
49 Correct 92 ms 6732 KB Output is correct
50 Correct 26 ms 2480 KB Output is correct
51 Correct 18 ms 1656 KB Output is correct
52 Correct 107 ms 8172 KB Output is correct
53 Correct 105 ms 7780 KB Output is correct
54 Correct 31 ms 2936 KB Output is correct
55 Correct 67 ms 5232 KB Output is correct
56 Correct 36 ms 4204 KB Output is correct
57 Correct 46 ms 4588 KB Output is correct
58 Correct 110 ms 8036 KB Output is correct
59 Correct 33 ms 2676 KB Output is correct
60 Correct 46 ms 3688 KB Output is correct