# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
963851 |
2024-04-15T20:05:40 Z |
Pekiban |
Meteors (POI11_met) |
C++17 |
|
1434 ms |
55732 KB |
#include <bits/stdc++.h>
using namespace std;
const int mxN = 3e5+3;
vector<int> a[mxN];
vector<array<int, 3>> v;
int p[mxN], ans[mxN], n, m, k, c = -1;
long long st[4*mxN], lz[4*mxN];
void push(int i, int l, int r) {
if (lz[i]) {
int mid = (l + r)/2;
lz[2*i] += lz[i];
st[2*i] += (mid - l + 1) * lz[i];
lz[2*i+1] += lz[i];
st[2*i+1] += (r - mid) * lz[i];
lz[i] = 0;
}
}
void update(int l, int r, long long x, int i = 1, int l2 = 0, int r2 = m-1) {
if (l <= l2 && r2 <= r) {
st[i] += x * (r2 - l2 + 1);
lz[i] += x;
return;
}
push(i, l2, r2);
int m2 = (l2 + r2)/2;
if (l <= m2) {
update(l, r, x, 2*i, l2, m2);
}
if (m2+1 <= r) {
update(l, r, x, 2*i+1, m2+1, r2);
}
st[i] = st[2*i] + st[2*i+1];
}
long long sum(int idx, int i = 1, int l2 = 0, int r2 = m-1) {
if (l2 == r2) {
return st[i];
}
push(i, l2, r2);
int m2 = (l2 + r2)/2;
return (idx <= m2 ? sum(idx, 2*i, l2, m2) : sum(idx, 2*i+1, m2+1, r2));
}
void solve(int l, int r, vector<int> b) {
int mid = (l + r)/2;
while (c < mid) {
++c;
if (v[c][0] <= v[c][1]) {
update(v[c][0], v[c][1], v[c][2]);
}
else {
update(v[c][0], m-1, v[c][2]);
update(0, v[c][1], v[c][2]);
}
}
while (c > mid) {
if (v[c][0] <= v[c][1]) {
update(v[c][0], v[c][1], -v[c][2]);
}
else {
update(v[c][0], m-1, -v[c][2]);
update(0, v[c][1], -v[c][2]);
}
--c;
}
vector<int> L, R;
for (auto x : b) {
long long s = 0;
for (auto i : a[x]) {
s += sum(i);
}
if (s >= p[x]) {
L.push_back(x);
ans[x] = mid;
}
else {
R.push_back(x);
}
}
b.clear();
if (l < mid && L.size()) {
solve(l, mid-1, L);
}
if (mid < r && R.size()) {
solve(mid+1, r, R);
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
fill(ans, ans+n, -1);
for (int i = 0; i < m; ++i) {
int x;
cin >> x;
--x;
a[x].push_back(i);
}
for (int i = 0; i < n; ++i) {
cin >> p[i];
}
cin >> k;
for (int i = 0; i < k; ++i) {
int l, r, x;
cin >> l >> r >> x;
--l, --r;
v.push_back({l, r, x});
}
vector<int> v(n);
iota(v.begin(), v.end(), 0);
solve(0, k-1, v);
for (int i = 0; i < n; ++i) {
cout << (ans[i] == -1 ? "NIE" : to_string(ans[i]+1)) << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
11868 KB |
Output is correct |
2 |
Correct |
5 ms |
12124 KB |
Output is correct |
3 |
Correct |
5 ms |
12052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
12124 KB |
Output is correct |
2 |
Correct |
4 ms |
12124 KB |
Output is correct |
3 |
Correct |
7 ms |
12120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
16676 KB |
Output is correct |
2 |
Correct |
196 ms |
18788 KB |
Output is correct |
3 |
Correct |
271 ms |
17228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
239 ms |
16684 KB |
Output is correct |
2 |
Correct |
225 ms |
15440 KB |
Output is correct |
3 |
Correct |
158 ms |
17600 KB |
Output is correct |
4 |
Correct |
69 ms |
15184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
118 ms |
14980 KB |
Output is correct |
2 |
Correct |
179 ms |
18096 KB |
Output is correct |
3 |
Correct |
45 ms |
13264 KB |
Output is correct |
4 |
Correct |
231 ms |
15984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
132 ms |
15108 KB |
Output is correct |
2 |
Correct |
219 ms |
16848 KB |
Output is correct |
3 |
Correct |
161 ms |
15056 KB |
Output is correct |
4 |
Correct |
251 ms |
18120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1434 ms |
55732 KB |
Output is correct |
2 |
Incorrect |
726 ms |
41904 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1251 ms |
51928 KB |
Output is correct |
2 |
Incorrect |
615 ms |
38688 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |