# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
963853 |
2024-04-15T20:12:26 Z |
Pekiban |
Meteors (POI11_met) |
C++17 |
|
1574 ms |
53908 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) {
if (b.empty()) return;
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 < r) {
solve(l, mid-1, L);
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 |
12052 KB |
Output is correct |
3 |
Correct |
5 ms |
11868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
12100 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 |
119 ms |
16668 KB |
Output is correct |
2 |
Correct |
206 ms |
18888 KB |
Output is correct |
3 |
Correct |
265 ms |
16732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
255 ms |
16692 KB |
Output is correct |
2 |
Correct |
239 ms |
15436 KB |
Output is correct |
3 |
Correct |
175 ms |
17600 KB |
Output is correct |
4 |
Correct |
71 ms |
15188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
113 ms |
14988 KB |
Output is correct |
2 |
Correct |
180 ms |
18088 KB |
Output is correct |
3 |
Correct |
43 ms |
13336 KB |
Output is correct |
4 |
Correct |
253 ms |
15812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
15108 KB |
Output is correct |
2 |
Correct |
218 ms |
16780 KB |
Output is correct |
3 |
Correct |
163 ms |
15008 KB |
Output is correct |
4 |
Correct |
259 ms |
17912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1574 ms |
53908 KB |
Output is correct |
2 |
Incorrect |
698 ms |
41936 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1387 ms |
51952 KB |
Output is correct |
2 |
Incorrect |
594 ms |
39372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |