# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
225303 |
2020-04-20T08:34:13 Z |
vioalbert |
Lasers (NOI19_lasers) |
C++14 |
|
135 ms |
10140 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 500005;
int k, n;
vector<pair<int, int>> seg;
int a[N];
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> k >> n;
for(int cn = 0; cn < n; cn++) {
int x; cin >> x;
int sumL = 0, sumR = 0;
for(int i = 0; i < x; i++) {
cin >> a[i];
sumR += a[i];
}
for(int i = 0; i < x; i++) {
sumR -= a[i];
int l = sumL+1, r = k-sumR;
int delta = (r-l+1) - a[i];
if(l + delta <= r - delta)
seg.push_back({l+delta, r-delta});
sumL += a[i];
}
}
sort(seg.begin(), seg.end());
stack<pair<int, int>> st;
for(auto& it : seg) {
if(st.empty() || st.top().second < it.first)
st.push(it);
else if(it.second > st.top().second) {
pair<int, int> u = {st.top().first, it.second};
st.pop();
st.push(u);
}
}
int ans = 0;
while(!st.empty()) {
ans += st.top().second - st.top().first + 1;
st.pop();
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
4 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 |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
4 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 |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
124 ms |
10140 KB |
Output is correct |
13 |
Correct |
5 ms |
384 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 |
134 ms |
7912 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
3892 KB |
Output is correct |
2 |
Correct |
12 ms |
1152 KB |
Output is correct |
3 |
Correct |
12 ms |
1024 KB |
Output is correct |
4 |
Correct |
45 ms |
4072 KB |
Output is correct |
5 |
Correct |
20 ms |
2332 KB |
Output is correct |
6 |
Correct |
33 ms |
3316 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
40 ms |
3312 KB |
Output is correct |
9 |
Correct |
25 ms |
3320 KB |
Output is correct |
10 |
Correct |
56 ms |
4328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
3892 KB |
Output is correct |
2 |
Correct |
12 ms |
1152 KB |
Output is correct |
3 |
Correct |
12 ms |
1024 KB |
Output is correct |
4 |
Correct |
45 ms |
4072 KB |
Output is correct |
5 |
Correct |
20 ms |
2332 KB |
Output is correct |
6 |
Correct |
33 ms |
3316 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
40 ms |
3312 KB |
Output is correct |
9 |
Correct |
25 ms |
3320 KB |
Output is correct |
10 |
Correct |
56 ms |
4328 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 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 |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
120 ms |
6756 KB |
Output is correct |
22 |
Correct |
21 ms |
1660 KB |
Output is correct |
23 |
Correct |
15 ms |
1408 KB |
Output is correct |
24 |
Correct |
51 ms |
3952 KB |
Output is correct |
25 |
Correct |
126 ms |
6760 KB |
Output is correct |
26 |
Correct |
44 ms |
3824 KB |
Output is correct |
27 |
Correct |
21 ms |
1536 KB |
Output is correct |
28 |
Correct |
127 ms |
6760 KB |
Output is correct |
29 |
Correct |
123 ms |
6760 KB |
Output is correct |
30 |
Correct |
37 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
4 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 |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
124 ms |
10140 KB |
Output is correct |
13 |
Correct |
5 ms |
384 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 |
134 ms |
7912 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
43 ms |
3892 KB |
Output is correct |
22 |
Correct |
12 ms |
1152 KB |
Output is correct |
23 |
Correct |
12 ms |
1024 KB |
Output is correct |
24 |
Correct |
45 ms |
4072 KB |
Output is correct |
25 |
Correct |
20 ms |
2332 KB |
Output is correct |
26 |
Correct |
33 ms |
3316 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
28 |
Correct |
40 ms |
3312 KB |
Output is correct |
29 |
Correct |
25 ms |
3320 KB |
Output is correct |
30 |
Correct |
56 ms |
4328 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
33 |
Correct |
5 ms |
384 KB |
Output is correct |
34 |
Correct |
5 ms |
384 KB |
Output is correct |
35 |
Correct |
5 ms |
384 KB |
Output is correct |
36 |
Correct |
5 ms |
384 KB |
Output is correct |
37 |
Correct |
5 ms |
384 KB |
Output is correct |
38 |
Correct |
5 ms |
384 KB |
Output is correct |
39 |
Correct |
5 ms |
384 KB |
Output is correct |
40 |
Correct |
5 ms |
384 KB |
Output is correct |
41 |
Correct |
120 ms |
6756 KB |
Output is correct |
42 |
Correct |
21 ms |
1660 KB |
Output is correct |
43 |
Correct |
15 ms |
1408 KB |
Output is correct |
44 |
Correct |
51 ms |
3952 KB |
Output is correct |
45 |
Correct |
126 ms |
6760 KB |
Output is correct |
46 |
Correct |
44 ms |
3824 KB |
Output is correct |
47 |
Correct |
21 ms |
1536 KB |
Output is correct |
48 |
Correct |
127 ms |
6760 KB |
Output is correct |
49 |
Correct |
123 ms |
6760 KB |
Output is correct |
50 |
Correct |
37 ms |
2552 KB |
Output is correct |
51 |
Correct |
22 ms |
1788 KB |
Output is correct |
52 |
Correct |
135 ms |
8044 KB |
Output is correct |
53 |
Correct |
123 ms |
7916 KB |
Output is correct |
54 |
Correct |
34 ms |
2936 KB |
Output is correct |
55 |
Correct |
81 ms |
5228 KB |
Output is correct |
56 |
Correct |
46 ms |
4336 KB |
Output is correct |
57 |
Correct |
51 ms |
4592 KB |
Output is correct |
58 |
Correct |
129 ms |
8040 KB |
Output is correct |
59 |
Correct |
40 ms |
2808 KB |
Output is correct |
60 |
Correct |
54 ms |
3824 KB |
Output is correct |