# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
869741 |
2023-11-05T13:09:01 Z |
riariti |
Meteors (POI11_met) |
C++17 |
|
5035 ms |
65536 KB |
#include <bits/stdc++.h>
#ifdef local
#include "../../local.hpp"
#else
#define dbg(...)
#endif
using i64 = long long;
constexpr int MXN = 3E5 + 9;
constexpr int MXM = 3E5 + 9;
i64 t[MXN * 4];
void build(int v, int l, int r) {
t[v] = 0;
if (l == r) {
t[v] = 0;
return;
}
int mid = (l + r) / 2;
build(v + v, l, mid);
build(v + v + 1, mid + 1, r);
}
void upd(int v, int l, int r, int ql, int qr, i64 x) {
if (ql <= l && r <= qr) {
t[v] += x;
return;
}
if (ql > r || qr < l) {
return;
}
int mid = (l + r) / 2;
upd(v + v, l, mid, ql, qr, x);
upd(v + v + 1, mid + 1, r, ql, qr, x);
}
i64 get(int v, int l, int r, int pos, i64 sum) {
sum += t[v];
if (l == r) {
return sum;
}
int mid = (l + r) / 2;
if (pos <= mid) {
return get(v + v, l, mid, pos, sum);
} else {
return get(v + v + 1, mid + 1, r, pos, sum);
}
}
int32_t main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr), std::cout.tie(nullptr);
#ifdef local
freopen("program.in", "r", stdin);
freopen("program.out", "w", stdout);
freopen("program.err", "w", stderr);
#endif
int n, m;
std::cin >> n >> m;
std::vector<int> o(m + 1);
for (int i = 1; i <= m; i++) {
std::cin >> o[i];
}
std::vector<int> p(n + 1);
for (int i = 1; i <= n; i++) {
std::cin >> p[i];
}
int k;
std::cin >> k;
std::vector<int> l(k + 1), r(k + 1), a(k + 1);
for (int i = 1; i <= k; i++) {
std::cin >> l[i] >> r[i] >> a[i];
}
std::map<int, std::vector<int>> ow;
for (int i = 1; i <= m; i++) {
ow[o[i]].push_back(i);
}
std::vector<int> lo(n + 1, 1), hi(n + 1, k + 1);
bool chk = true;
std::map<int, std::set<int>> wrk;
while (chk) {
chk = false;
build(1, 1, m);
for (int i = 1; i <= n; i++) {
if (lo[i] == hi[i]) {
continue;
}
int m = (lo[i] + hi[i]) / 2;
wrk[m].insert(i);
}
for (int q = 1; q <= k; q++) {
if (l[q] <= r[q]) {
upd(1, 1, m, l[q], r[q], a[q]);
} else {
upd(1, 1, m, 1, r[q], a[q]);
upd(1, 1, m, l[q], m, a[q]);
}
for (auto x : wrk[q]) {
chk = true;
i64 su = 0;
for (auto pls : ow[x]) {
su += get(1, 1, m, pls, 0);
if (su >= p[x]) {
break;
}
}
if (su >= p[x]) {
hi[x] = q;
} else {
lo[x] = q + 1;
}
}
}
for (int i = 1; i <= k; i++) {
wrk[i].clear();
}
}
for (int i = 1; i <= n; i++) {
if (lo[i] <= k) {
std::cout << lo[i] << "\n";
} else {
std::cout << "NIE\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
600 KB |
Output is correct |
2 |
Correct |
4 ms |
604 KB |
Output is correct |
3 |
Correct |
4 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
600 KB |
Output is correct |
2 |
Correct |
5 ms |
600 KB |
Output is correct |
3 |
Correct |
5 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
367 ms |
8956 KB |
Output is correct |
2 |
Correct |
513 ms |
12200 KB |
Output is correct |
3 |
Correct |
476 ms |
10320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
435 ms |
10000 KB |
Output is correct |
2 |
Correct |
450 ms |
9844 KB |
Output is correct |
3 |
Correct |
523 ms |
12360 KB |
Output is correct |
4 |
Correct |
97 ms |
5980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
274 ms |
9296 KB |
Output is correct |
2 |
Correct |
412 ms |
12360 KB |
Output is correct |
3 |
Correct |
236 ms |
5972 KB |
Output is correct |
4 |
Correct |
484 ms |
11156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
382 ms |
8480 KB |
Output is correct |
2 |
Correct |
412 ms |
9936 KB |
Output is correct |
3 |
Correct |
381 ms |
8784 KB |
Output is correct |
4 |
Correct |
549 ms |
12396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5035 ms |
59624 KB |
Output is correct |
2 |
Correct |
2322 ms |
43100 KB |
Output is correct |
3 |
Correct |
1543 ms |
29560 KB |
Output is correct |
4 |
Runtime error |
425 ms |
65536 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4999 ms |
57536 KB |
Output is correct |
2 |
Correct |
1903 ms |
42968 KB |
Output is correct |
3 |
Correct |
1300 ms |
25100 KB |
Output is correct |
4 |
Runtime error |
335 ms |
65536 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |