# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1087223 |
2024-09-12T10:10:26 Z |
avighna |
Lasers (NOI19_lasers) |
C++17 |
|
633 ms |
72348 KB |
#include <bits/stdc++.h>
typedef long long ll;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
ll l, r;
std::cin >> l >> r;
std::vector<std::vector<ll>> rows(r);
std::vector<ll> left(r), sum(r);
std::priority_queue<std::pair<ll, ll>, std::vector<std::pair<ll, ll>>,
std::greater<>>
pq;
std::multiset<ll> st;
auto f = [&](ll cnt) { return l - (sum[cnt] - left[cnt]) + 1; };
for (ll cnt = 0; cnt < r; ++cnt) {
auto &v = rows[cnt];
ll len;
std::cin >> len;
v.resize(len);
for (auto &i : v) {
std::cin >> i;
}
std::reverse(v.begin(), v.end());
sum[cnt] = std::accumulate(v.begin(), v.end(), 0LL);
pq.push({left[cnt] + v.back(), cnt});
v.pop_back();
st.insert(f(cnt));
}
auto range = [](ll l, ll r, ll c) {
if (r <= c) {
return r - l + 1;
} else if (l > c) {
return 0LL;
}
return c - l + 1;
};
ll ans = l, i = 1;
while (i <= l) {
while (!pq.empty() and pq.top().first < i) {
auto [l, j] = pq.top();
pq.pop();
st.erase(st.find(f(j)));
left[j] = l;
st.insert(f(j));
if (!rows[j].empty()) {
pq.push({left[j] + rows[j].back(), j});
rows[j].pop_back();
}
}
ll end = !pq.empty() ? pq.top().first : l;
ans -= range(i + 1, ++end, *st.begin());
i = end;
}
std::cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 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 |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 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 |
182 ms |
71288 KB |
Output is correct |
13 |
Correct |
0 ms |
344 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 |
633 ms |
72348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
3420 KB |
Output is correct |
2 |
Correct |
6 ms |
1116 KB |
Output is correct |
3 |
Correct |
8 ms |
1372 KB |
Output is correct |
4 |
Correct |
25 ms |
3488 KB |
Output is correct |
5 |
Correct |
11 ms |
1884 KB |
Output is correct |
6 |
Correct |
30 ms |
4420 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
38 ms |
5012 KB |
Output is correct |
9 |
Correct |
14 ms |
1880 KB |
Output is correct |
10 |
Correct |
28 ms |
3780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
448 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
452 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 |
460 KB |
Output is correct |
10 |
Correct |
0 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
3420 KB |
Output is correct |
2 |
Correct |
6 ms |
1116 KB |
Output is correct |
3 |
Correct |
8 ms |
1372 KB |
Output is correct |
4 |
Correct |
25 ms |
3488 KB |
Output is correct |
5 |
Correct |
11 ms |
1884 KB |
Output is correct |
6 |
Correct |
30 ms |
4420 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
38 ms |
5012 KB |
Output is correct |
9 |
Correct |
14 ms |
1880 KB |
Output is correct |
10 |
Correct |
28 ms |
3780 KB |
Output is correct |
11 |
Correct |
0 ms |
448 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
452 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 |
460 KB |
Output is correct |
20 |
Correct |
0 ms |
452 KB |
Output is correct |
21 |
Correct |
613 ms |
70572 KB |
Output is correct |
22 |
Correct |
39 ms |
2136 KB |
Output is correct |
23 |
Correct |
13 ms |
1372 KB |
Output is correct |
24 |
Correct |
62 ms |
5132 KB |
Output is correct |
25 |
Correct |
590 ms |
70576 KB |
Output is correct |
26 |
Correct |
86 ms |
3676 KB |
Output is correct |
27 |
Correct |
32 ms |
1660 KB |
Output is correct |
28 |
Correct |
588 ms |
70320 KB |
Output is correct |
29 |
Correct |
607 ms |
70760 KB |
Output is correct |
30 |
Correct |
57 ms |
3956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 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 |
182 ms |
71288 KB |
Output is correct |
13 |
Correct |
0 ms |
344 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 |
633 ms |
72348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
25 ms |
3420 KB |
Output is correct |
22 |
Correct |
6 ms |
1116 KB |
Output is correct |
23 |
Correct |
8 ms |
1372 KB |
Output is correct |
24 |
Correct |
25 ms |
3488 KB |
Output is correct |
25 |
Correct |
11 ms |
1884 KB |
Output is correct |
26 |
Correct |
30 ms |
4420 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
38 ms |
5012 KB |
Output is correct |
29 |
Correct |
14 ms |
1880 KB |
Output is correct |
30 |
Correct |
28 ms |
3780 KB |
Output is correct |
31 |
Correct |
0 ms |
448 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
452 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 |
460 KB |
Output is correct |
40 |
Correct |
0 ms |
452 KB |
Output is correct |
41 |
Correct |
613 ms |
70572 KB |
Output is correct |
42 |
Correct |
39 ms |
2136 KB |
Output is correct |
43 |
Correct |
13 ms |
1372 KB |
Output is correct |
44 |
Correct |
62 ms |
5132 KB |
Output is correct |
45 |
Correct |
590 ms |
70576 KB |
Output is correct |
46 |
Correct |
86 ms |
3676 KB |
Output is correct |
47 |
Correct |
32 ms |
1660 KB |
Output is correct |
48 |
Correct |
588 ms |
70320 KB |
Output is correct |
49 |
Correct |
607 ms |
70760 KB |
Output is correct |
50 |
Correct |
57 ms |
3956 KB |
Output is correct |
51 |
Correct |
18 ms |
1880 KB |
Output is correct |
52 |
Correct |
594 ms |
71340 KB |
Output is correct |
53 |
Correct |
630 ms |
71600 KB |
Output is correct |
54 |
Correct |
59 ms |
3672 KB |
Output is correct |
55 |
Correct |
144 ms |
7348 KB |
Output is correct |
56 |
Correct |
49 ms |
4556 KB |
Output is correct |
57 |
Correct |
92 ms |
4696 KB |
Output is correct |
58 |
Correct |
628 ms |
72072 KB |
Output is correct |
59 |
Correct |
69 ms |
3420 KB |
Output is correct |
60 |
Correct |
101 ms |
5040 KB |
Output is correct |