Submission #906449

# Submission time Handle Problem Language Result Execution time Memory
906449 2024-01-14T10:06:06 Z starchan Lasers (NOI19_lasers) C++17
100 / 100
303 ms 34092 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define LMX (int)2e6+69
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
int ok(int a, int b, int c)
{
	//in [a, b] with <= c
	if(c < a)
		return 0;
	return min(b, c)-a+1;
}
struct seg_tree
{
	vector<int> tree;
	void init(int n)
	{
		tree.assign(4*n+69, 0);
		return;
	}
	void upd(int val, int pos, int id, int l, int r)
	{
		if(l == r)
		{
			tree[id] = val;
			return;
		}
		int m = (l+r)/2;
		if(pos <= m)
			upd(val, pos, 2*id, l, m);
		else
			upd(val, pos, 2*id+1, m+1, r);
		tree[id] = min(tree[2*id], tree[2*id+1]);
		return;
	}
	int rep()
	{
		return tree[1];
	}
};
signed main()
{
	fast();
	seg_tree work;
	int L, n;
	cin >> L >> n;
	work.init(n);
	vector<in> p;
	vector<int> v;
	vector<int> a(n+1);
	for(int i = 1; i <= n; i++)
	{
		int c;
		cin >> c;
		v.resize(c+1);
		v[0] = 0;
		for(int j = 1; j <= c; j++)
		{
			cin >> v[j];
			v[j]+=v[j-1];
			p.pb({v[j], i});
		}
		a[i] = L-v[c];
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
		work.upd(a[i], i, 1, 1, n);
	sort(p.begin(), p.end());
	p.pb({L, 1});
	vector<int> upd;
	int prev = 0;
	for(auto [pr, W]: p)
	{
		if(pr > prev)
			ans+=ok(prev+1, pr, work.rep());
		prev = pr;
		work.upd(pr+a[W], W, 1, 1, n);
	}
	ans = L-ans;
	cout << ans << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 452 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 452 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 156 ms 33468 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 238 ms 34092 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 12272 KB Output is correct
2 Correct 8 ms 3288 KB Output is correct
3 Correct 9 ms 3288 KB Output is correct
4 Correct 34 ms 10724 KB Output is correct
5 Correct 25 ms 6348 KB Output is correct
6 Correct 40 ms 13776 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 52 ms 12172 KB Output is correct
9 Correct 17 ms 6612 KB Output is correct
10 Correct 39 ms 11084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 12272 KB Output is correct
2 Correct 8 ms 3288 KB Output is correct
3 Correct 9 ms 3288 KB Output is correct
4 Correct 34 ms 10724 KB Output is correct
5 Correct 25 ms 6348 KB Output is correct
6 Correct 40 ms 13776 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 52 ms 12172 KB Output is correct
9 Correct 17 ms 6612 KB Output is correct
10 Correct 39 ms 11084 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 231 ms 32444 KB Output is correct
22 Correct 24 ms 3024 KB Output is correct
23 Correct 12 ms 3280 KB Output is correct
24 Correct 54 ms 12052 KB Output is correct
25 Correct 230 ms 32184 KB Output is correct
26 Correct 51 ms 11452 KB Output is correct
27 Correct 20 ms 3024 KB Output is correct
28 Correct 303 ms 31916 KB Output is correct
29 Correct 274 ms 32188 KB Output is correct
30 Correct 42 ms 11844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 452 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 156 ms 33468 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 238 ms 34092 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 33 ms 12272 KB Output is correct
22 Correct 8 ms 3288 KB Output is correct
23 Correct 9 ms 3288 KB Output is correct
24 Correct 34 ms 10724 KB Output is correct
25 Correct 25 ms 6348 KB Output is correct
26 Correct 40 ms 13776 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 52 ms 12172 KB Output is correct
29 Correct 17 ms 6612 KB Output is correct
30 Correct 39 ms 11084 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 231 ms 32444 KB Output is correct
42 Correct 24 ms 3024 KB Output is correct
43 Correct 12 ms 3280 KB Output is correct
44 Correct 54 ms 12052 KB Output is correct
45 Correct 230 ms 32184 KB Output is correct
46 Correct 51 ms 11452 KB Output is correct
47 Correct 20 ms 3024 KB Output is correct
48 Correct 303 ms 31916 KB Output is correct
49 Correct 274 ms 32188 KB Output is correct
50 Correct 42 ms 11844 KB Output is correct
51 Correct 16 ms 3156 KB Output is correct
52 Correct 234 ms 33408 KB Output is correct
53 Correct 234 ms 33400 KB Output is correct
54 Correct 38 ms 7628 KB Output is correct
55 Correct 92 ms 11880 KB Output is correct
56 Correct 42 ms 10952 KB Output is correct
57 Correct 59 ms 12744 KB Output is correct
58 Correct 237 ms 33216 KB Output is correct
59 Correct 43 ms 7116 KB Output is correct
60 Correct 61 ms 11456 KB Output is correct