# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1087180 |
2024-09-12T09:12:50 Z |
avighna |
Lasers (NOI19_lasers) |
C++17 |
|
1000 ms |
70868 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::priority_queue<std::pair<ll, ll>, std::vector<std::pair<ll, ll>>,
std::greater<>>
pq;
std::vector<ll> left(r), sum(r);
std::vector<std::vector<ll>> rows(r);
std::multiset<ll> st;
// x blocks from right ==> l - x + 1 from left
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));
}
ll ans = l;
for (ll _i = 1; _i <= l; ++_i) {
while (!pq.empty() and pq.top().first < _i) {
auto [l, i] = pq.top();
pq.pop();
st.erase(st.find(f(i)));
left[i] = l;
st.insert(f(i));
if (!rows[i].empty()) {
pq.push({left[i] + rows[i].back(), i});
rows[i].pop_back();
}
}
ans -= *st.begin() >= _i + 1;
}
std::cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
867 ms |
348 KB |
Output is correct |
2 |
Correct |
400 ms |
348 KB |
Output is correct |
3 |
Correct |
798 ms |
432 KB |
Output is correct |
4 |
Execution timed out |
1089 ms |
348 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
867 ms |
348 KB |
Output is correct |
2 |
Correct |
400 ms |
348 KB |
Output is correct |
3 |
Correct |
798 ms |
432 KB |
Output is correct |
4 |
Execution timed out |
1089 ms |
348 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
3416 KB |
Output is correct |
2 |
Correct |
8 ms |
1068 KB |
Output is correct |
3 |
Correct |
12 ms |
1404 KB |
Output is correct |
4 |
Correct |
30 ms |
3416 KB |
Output is correct |
5 |
Correct |
19 ms |
1884 KB |
Output is correct |
6 |
Correct |
39 ms |
4188 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
42 ms |
4884 KB |
Output is correct |
9 |
Correct |
17 ms |
2100 KB |
Output is correct |
10 |
Correct |
31 ms |
3672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 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 |
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 |
0 ms |
360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
3416 KB |
Output is correct |
2 |
Correct |
8 ms |
1068 KB |
Output is correct |
3 |
Correct |
12 ms |
1404 KB |
Output is correct |
4 |
Correct |
30 ms |
3416 KB |
Output is correct |
5 |
Correct |
19 ms |
1884 KB |
Output is correct |
6 |
Correct |
39 ms |
4188 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
42 ms |
4884 KB |
Output is correct |
9 |
Correct |
17 ms |
2100 KB |
Output is correct |
10 |
Correct |
31 ms |
3672 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 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 |
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 |
0 ms |
360 KB |
Output is correct |
21 |
Correct |
697 ms |
70724 KB |
Output is correct |
22 |
Correct |
46 ms |
2140 KB |
Output is correct |
23 |
Correct |
17 ms |
1460 KB |
Output is correct |
24 |
Correct |
72 ms |
4956 KB |
Output is correct |
25 |
Correct |
763 ms |
70664 KB |
Output is correct |
26 |
Correct |
98 ms |
3676 KB |
Output is correct |
27 |
Correct |
38 ms |
1744 KB |
Output is correct |
28 |
Correct |
705 ms |
70544 KB |
Output is correct |
29 |
Correct |
733 ms |
70868 KB |
Output is correct |
30 |
Correct |
56 ms |
4052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
867 ms |
348 KB |
Output is correct |
2 |
Correct |
400 ms |
348 KB |
Output is correct |
3 |
Correct |
798 ms |
432 KB |
Output is correct |
4 |
Execution timed out |
1089 ms |
348 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |