# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1087165 |
2024-09-12T09:02:35 Z |
avighna |
Lasers (NOI19_lasers) |
C++17 |
|
245 ms |
262144 KB |
#include <bits/stdc++.h>
class FenwickTree {
public:
std::vector<int> f;
int n;
FenwickTree(int n) {
this->n = n;
f.resize(n + 1);
}
void add(int idx, int del) {
for (int i = idx; i <= n; i += i & (-i)) {
f[i] += del;
}
}
int query(int idx) {
int ans = 0;
for (int i = idx; i >= 1; i -= i & (-i)) {
ans += f[i];
}
return ans;
}
int query(int l, int r) {
if (l > r) {
return 0;
}
int ans = query(r);
if (l - 1 >= 1) {
ans -= query(l - 1);
}
return ans;
}
};
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int l, r;
std::cin >> l >> r;
std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>,
std::greater<>>
pq;
std::vector<int> left(r), sum(r);
std::vector<std::vector<int>> rows(r);
FenwickTree tree(l + 1);
// x blocks from right ==> l - x + 1 from left
auto f = [&](int cnt) { return l - (sum[cnt] - left[cnt]) + 1; };
for (int cnt = 0; cnt < r; ++cnt) {
auto &v = rows[cnt];
int 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(), 0);
pq.push({left[cnt] + v.back(), cnt});
v.pop_back();
tree.add(f(cnt), 1);
}
int ans = 0;
for (int _i = 1; _i <= l; ++_i) {
while (!pq.empty() and pq.top().first < _i) {
auto [l, i] = pq.top();
pq.pop();
tree.add(f(i), -1);
left[i] = l;
tree.add(f(i), 1);
if (!rows[i].empty()) {
pq.push({left[i] + rows[i].back(), i});
rows[i].pop_back();
}
}
int gs = tree.query(_i + 1, l + 1);
// for (int j = 0; j < r; ++j) {
// gs += _i < l - (sum[j] - left[j]) + 1;
// }
ans += gs != r;
}
std::cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
132 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
132 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
5720 KB |
Output is correct |
2 |
Correct |
22 ms |
4444 KB |
Output is correct |
3 |
Correct |
25 ms |
4700 KB |
Output is correct |
4 |
Correct |
48 ms |
5780 KB |
Output is correct |
5 |
Correct |
30 ms |
5212 KB |
Output is correct |
6 |
Correct |
58 ms |
6236 KB |
Output is correct |
7 |
Correct |
12 ms |
3676 KB |
Output is correct |
8 |
Correct |
62 ms |
6232 KB |
Output is correct |
9 |
Correct |
29 ms |
5076 KB |
Output is correct |
10 |
Correct |
47 ms |
5980 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 |
0 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 |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 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 |
45 ms |
5720 KB |
Output is correct |
2 |
Correct |
22 ms |
4444 KB |
Output is correct |
3 |
Correct |
25 ms |
4700 KB |
Output is correct |
4 |
Correct |
48 ms |
5780 KB |
Output is correct |
5 |
Correct |
30 ms |
5212 KB |
Output is correct |
6 |
Correct |
58 ms |
6236 KB |
Output is correct |
7 |
Correct |
12 ms |
3676 KB |
Output is correct |
8 |
Correct |
62 ms |
6232 KB |
Output is correct |
9 |
Correct |
29 ms |
5076 KB |
Output is correct |
10 |
Correct |
47 ms |
5980 KB |
Output is correct |
11 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 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 |
235 ms |
42892 KB |
Output is correct |
22 |
Correct |
45 ms |
4956 KB |
Output is correct |
23 |
Correct |
31 ms |
4696 KB |
Output is correct |
24 |
Correct |
71 ms |
6748 KB |
Output is correct |
25 |
Correct |
232 ms |
42976 KB |
Output is correct |
26 |
Correct |
62 ms |
5980 KB |
Output is correct |
27 |
Correct |
35 ms |
4952 KB |
Output is correct |
28 |
Correct |
229 ms |
42776 KB |
Output is correct |
29 |
Correct |
245 ms |
43196 KB |
Output is correct |
30 |
Correct |
62 ms |
5980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
132 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |