# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
964321 |
2024-04-16T16:04:53 Z |
Pekiban |
Meteors (POI11_met) |
C++17 |
|
453 ms |
24848 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mxN = 3e5+3;
vector<int> a[mxN];
array<int, 3> e[mxN];
ll bit[mxN], p[mxN], ans[mxN], c;
void upd(int idx, int x) {
while (idx < mxN) {
bit[idx] += x;
idx |= (idx + 1);
}
}
ll sum(ll idx) {
ll s = 0;
while (idx >= 0) {
s += bit[idx];
idx &= (idx + 1);
--idx;
}
return s;
}
void add(int idx, int x) {
if (e[idx][0] <= e[idx][1]) {
upd(e[idx][1] + 1, -e[idx][2] * x);
upd(e[idx][0], e[idx][1] * x);
}
else {
upd(e[idx][1] + 1, -e[idx][2] * x);
upd(1, e[idx][2] * x);
upd(e[idx][0], e[idx][2] * x);
}
}
int n, m, k;
void solve(int l, int r, vector<int> &b) {
if (b.empty()) return;
if (l == r) {
if (l == k+1) {
for (auto u : b) {
ans[u] = -1;
}
}
else {
for (auto u : b) {
ans[u] = l;
}
}
return;
}
int mid = (l + r)/2;
while (c < mid) {
++c;
add(c, 1);
}
while (c > mid) {
add(c, -1);
--c;
}
vector<int> L, R;
for (auto x : b) {
ll s = 0;
for (auto i : a[x]) {
s += sum(i);
}
if (s >= p[x]) {
L.push_back(x);
}
else {
R.push_back(x);
}
}
b.clear();
if (!L.empty()) solve(l, mid, L);
if (!R.empty()) solve(mid+1, r, R);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; ++i) {
int x;
cin >> x;
a[x].push_back(i);
}
for (int i = 1; i <= n; ++i) {
cin >> p[i];
}
cin >> k;
for (int i = 1; i <= k; ++i) {
cin >> e[i][0] >> e[i][1] >> e[i][2];
}
vector<int> b;
for (int i = 1; i <= n; ++i) b.push_back(i);
solve(1, k+1, b);
for (int i = 1; i <= n; ++i) {
if (ans[i] == -1) {
cout << "NIE" << '\n';
}
else {
cout << ans[i] << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
13656 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
13660 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
14420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
61 ms |
14540 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
14428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
13912 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
453 ms |
24140 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
443 ms |
24848 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |