Submission #500568

# Submission time Handle Problem Language Result Execution time Memory
500568 2021-12-31T11:36:17 Z pooty Lasers (NOI19_lasers) C++17
100 / 100
249 ms 44636 KB
#define REP(i, n) for(int i = 0; i < n; i ++)
#define REPL(i,m, n) for(int i = m; i < n; i ++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define SORT(arr) sort(arr.begin(), arr.end())
#define LSOne(S) ((S)&-(S))
#define M_PI 3.1415926535897932384
#define INF 999999999
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int l,r;cin>>l>>r;
	vvi rarr(r);
	REP(i, r) {
		int x;cin>>x;
		REP(j, x) {
			int c;cin>>c;
			rarr[i].push_back(c);
		}
	}
	set<ii> intervals;
	for (auto vec: rarr) {
		//cout<<"...\n";
		int gap = l - accumulate(vec.begin(), vec.end(), 0);
		int curright = gap;
		int curtot = 0;
		for (auto x: vec) {
			curtot += x;
			if (curtot - 1 >= curright) {
				intervals.insert({curright, curtot - 1});
				//cout<<curright<<" "<<curtot-1<<"\n";
			}
			curright = curtot + gap;
		}
	}
	int totblock = 0;
	while (!intervals.empty()) {
		auto [l,r] = *intervals.begin();
		int curl = l;
		int curr = r;
		while (!intervals.empty()) {
			auto [nl,nr] = *intervals.begin();
			if (nl <= curr) {
				intervals.erase(intervals.begin());
				curr = max(curr, nr);
			} else {
				break;
			}
		}
		totblock += (curr - curl +1);
	}
	cout<<totblock<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 312 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 272 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 312 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 272 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 108 ms 32848 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 230 ms 43072 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 10740 KB Output is correct
2 Correct 9 ms 2124 KB Output is correct
3 Correct 8 ms 1664 KB Output is correct
4 Correct 54 ms 11552 KB Output is correct
5 Correct 19 ms 4776 KB Output is correct
6 Correct 29 ms 5268 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 36 ms 7132 KB Output is correct
9 Correct 39 ms 8072 KB Output is correct
10 Correct 63 ms 13340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 10740 KB Output is correct
2 Correct 9 ms 2124 KB Output is correct
3 Correct 8 ms 1664 KB Output is correct
4 Correct 54 ms 11552 KB Output is correct
5 Correct 19 ms 4776 KB Output is correct
6 Correct 29 ms 5268 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 36 ms 7132 KB Output is correct
9 Correct 39 ms 8072 KB Output is correct
10 Correct 63 ms 13340 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 312 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 308 KB Output is correct
21 Correct 202 ms 40768 KB Output is correct
22 Correct 26 ms 4564 KB Output is correct
23 Correct 19 ms 3228 KB Output is correct
24 Correct 61 ms 11680 KB Output is correct
25 Correct 191 ms 40516 KB Output is correct
26 Correct 59 ms 9348 KB Output is correct
27 Correct 23 ms 3828 KB Output is correct
28 Correct 205 ms 40424 KB Output is correct
29 Correct 188 ms 40644 KB Output is correct
30 Correct 40 ms 8476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 312 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 272 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 108 ms 32848 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 230 ms 43072 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 54 ms 10740 KB Output is correct
22 Correct 9 ms 2124 KB Output is correct
23 Correct 8 ms 1664 KB Output is correct
24 Correct 54 ms 11552 KB Output is correct
25 Correct 19 ms 4776 KB Output is correct
26 Correct 29 ms 5268 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 36 ms 7132 KB Output is correct
29 Correct 39 ms 8072 KB Output is correct
30 Correct 63 ms 13340 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 0 ms 312 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 308 KB Output is correct
41 Correct 202 ms 40768 KB Output is correct
42 Correct 26 ms 4564 KB Output is correct
43 Correct 19 ms 3228 KB Output is correct
44 Correct 61 ms 11680 KB Output is correct
45 Correct 191 ms 40516 KB Output is correct
46 Correct 59 ms 9348 KB Output is correct
47 Correct 23 ms 3828 KB Output is correct
48 Correct 205 ms 40424 KB Output is correct
49 Correct 188 ms 40644 KB Output is correct
50 Correct 40 ms 8476 KB Output is correct
51 Correct 21 ms 4584 KB Output is correct
52 Correct 226 ms 44092 KB Output is correct
53 Correct 248 ms 43960 KB Output is correct
54 Correct 42 ms 6460 KB Output is correct
55 Correct 108 ms 15284 KB Output is correct
56 Correct 82 ms 10672 KB Output is correct
57 Correct 72 ms 10816 KB Output is correct
58 Correct 249 ms 44636 KB Output is correct
59 Correct 50 ms 8004 KB Output is correct
60 Correct 84 ms 10384 KB Output is correct