# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
587351 |
2022-07-01T16:57:05 Z |
LittlePants |
Meteors (POI11_met) |
C++17 |
|
374 ms |
65536 KB |
#define ll loli
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define push emplace
#define lb(x, v) lower_bound(all(x), v)
#define ub(x, v) upper_bound(all(x), v)
#define sz(x) (int)(x.size())
#define re(x) reverse(all(x))
#define uni(x) x.resize(unique(all(x)) - x.begin())
#define all(x) x.begin(), x.end()
#define mem(x, v) memset(x, v, sizeof x);
#define int long long
#define pii pair<int, int>
#define inf 1000000000
#define INF 1000000000000000000
#define mod 1000000007
#define F first
#define S second
#define IO ios_base::sync_with_stdio(0); cin.tie(0);
#define chmax(a, b) (a = (b > a ? b : a))
#define chmin(a, b) (a = (b < a ? b : a))
#define get_bit(x, y) ((x>>y)&1)
#define mkp make_pair
using namespace std;
#ifdef loli
void trace_() {cerr << "\n";}
template<typename T1, typename... T2> void trace_(T1 t1, T2... t2) {cerr << ' ' << t1; trace_(t2...); }
#define trace(...) cerr << "[" << #__VA_ARGS__ << "] :", trace_(__VA_ARGS__);
#else
#define trace(...) 49
#endif
const int mxN = 3e5 + 5;
int n, m, k, a[mxN], ans[mxN];
bool cmp(array<int, 3> a, array<int, 3> b) {
if (a[1] == b[1]) return (a[0] == 0 ? INF : a[0]) < (b[0] == 0 ? INF : b[0]);
return a[1] < b[1];
}
void bs(vector<array<int, 3>> &v, int l, int r) {
if (l == r) {
for (auto [i, p, o] : v) {
if (!i) ans[o] = l;
}
return;
}
int mid = (l + r) >> 1, res = 0;
vector<array<int, 3>> va, vb;
for (auto [i, x, val] : v) {
if (i and i <= mid) res += val;
if (!i) a[val] -= res;
}
while (!v.empty()) {
auto [i, x, val] = v.back();
v.pop_back();
if (i) {
if (i <= mid) va.pb({i, x, val});
else vb.pb({i, x, val});
} else {
if (a[val] <= 0) va.pb({i, x, val});
else vb.pb({i, x, val});
}
}
re(va);
re(vb);
res = 0;
for (auto [i, x, val] : va) {
if (i) res += val;
else a[val] += res;
}
bs(va, l, mid);
bs(vb, mid+1, r);
}
inline void solve() {
cin >> n >> m;
vector<int> o(m + 1);
for (int i = 1; i <= m; i++) cin >> o[i];
for (int i = 1; i <= n; i++) cin >> a[i];
vector<array<int, 3>> v;
for (int i = 1; i <= m; i++) {
v.pb({0, i, o[i]});
}
cin >> k;
for (int i = 1; i <= k; i++) {
int l, r, x; cin >> l >> r >> x;
if (l > r) {
v.pb({i, l, x});
v.pb({i, 1, x});
v.pb({i, r + 1, -x});
} else {
v.pb({i, l, x});
if (r + 1 <= m) v.pb({i, r + 1, -x});
}
}
sort(all(v), cmp);
bs(v, 1, k + 1);
for (int i = 1; i <= n; i++) {
if (ans[i] == 0 or ans[i] == k + 1) cout << "NIE\n";
else cout << ans[i] << '\n';
}
}
signed main() {
IO;
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
596 KB |
Output is correct |
2 |
Correct |
2 ms |
724 KB |
Output is correct |
3 |
Correct |
2 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
852 KB |
Output is correct |
2 |
Correct |
2 ms |
852 KB |
Output is correct |
3 |
Correct |
2 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
24924 KB |
Output is correct |
2 |
Correct |
121 ms |
33688 KB |
Output is correct |
3 |
Correct |
111 ms |
16036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
15736 KB |
Output is correct |
2 |
Correct |
113 ms |
15368 KB |
Output is correct |
3 |
Correct |
124 ms |
27212 KB |
Output is correct |
4 |
Correct |
31 ms |
12516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
16316 KB |
Output is correct |
2 |
Correct |
111 ms |
27908 KB |
Output is correct |
3 |
Correct |
85 ms |
9352 KB |
Output is correct |
4 |
Correct |
109 ms |
15720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
27928 KB |
Output is correct |
2 |
Correct |
116 ms |
24744 KB |
Output is correct |
3 |
Correct |
96 ms |
15408 KB |
Output is correct |
4 |
Correct |
129 ms |
19888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
350 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
374 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |