# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1015750 |
2024-07-06T18:02:58 Z |
vjudge1 |
Meteors (POI11_met) |
C++14 |
|
1281 ms |
65540 KB |
//
// main1.cpp
// problem1
//
// Created by Essa Almousa on 2030 / 01/ 01 AD.
//
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using ll = int;
using ll1 = int;
#define pb push_back
#define pF first
#define pS second
#define SP <<" "<<
const ll N = 3e5+1, offset = 1 << 19;
struct segment {
vector<ll> tree;
void again() {
tree.clear();
tree.resize(2 * offset);
}
void upd(ll v, ll l, ll r, ll ql, ll qr, ll x) {
if (l >= qr || r <= ql) return;
if (l >= ql && r <= qr) {tree[v] = min(tree[v] + x, (int)1e9); return;}
ll mi = (l+r)/2;
upd(v*2, l, mi, ql, qr, x);
upd(v*2+1, mi, r, ql, qr, x);
}
ll query(ll i) {
i--;
i += offset;
ll ans = 0;
while (i >= 1) {
ans = min(ans + tree[i], (int)1e9);
i /= 2;
}
return ans;
}
void upd(ll l, ll r, ll val) {return upd(1, 0, offset, l-1, r, val);}
};
struct query_ {
ll l, r, x;
};
ll a[N], b[N];
ll1 sol[N];
vector<ll> frq[N];
query_ q[N];
int main() {
//ios::sync_with_stdio(0); cout.tie(0); cin.tie(0);
ll1 n, m;
cin>>n>>m;
for (ll i=1; i<=m; i++) {
int temp; cin >> temp;
a[i] = temp;
//cin>>a[i];
frq[a[i]].pb(i);
}
for (ll i=1; i<=n; i++) {
int temp; cin >> temp;
b[i] = temp;
//cin>>b[i];
}
ll1 q1;
cin>>q1;
struct binnode { ll i, l, r; };
vector<binnode> bin[N];
for (ll i=1; i<=n; i++) {
ll mi = q1+1/2;
bin[mi].pb({i, 1, q1});
sol[i] = -1;
}
for (ll i=1; i<=q1; i++) {
ll1 l, r, x;
cin>>l>>r>>x;
q[i] = {l, r, x};
}
ll1 cnt = n;
segment tree;
while (cnt > 0) {
tree.again();
for (ll i=1; i<=q1; i++) {
if (q[i].l > q[i].r) {
tree.upd(q[i].l, m, q[i].x);
tree.upd(1, q[i].r, q[i].x);
}
else tree.upd(q[i].l, q[i].r, q[i].x);
while(!bin[i].empty()) {
binnode x = bin[i].back();
bin[i].pop_back();
int ans = 0;
for (auto k : frq[x.i]) {
ans = min(ans + tree.query(k), (int)1e9);
}
if (ans >= b[x.i]) {
sol[x.i] = i;
x.r = i - 1;
}
else {
x.l = i + 1;
}
if (x.l > x.r) {
cnt--;
}
else {
bin[(x.l + x.r) / 2].push_back(x);
}
}
}
}
for (ll i=1; i<=n; i++) {
if (sol[i] == -1) cout << "NIE" << endl;
else cout << sol[i] << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
21852 KB |
Output is correct |
2 |
Correct |
9 ms |
21680 KB |
Output is correct |
3 |
Correct |
10 ms |
21852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
21852 KB |
Output is correct |
2 |
Correct |
10 ms |
21848 KB |
Output is correct |
3 |
Correct |
11 ms |
21852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
199 ms |
24688 KB |
Output is correct |
2 |
Correct |
222 ms |
25164 KB |
Output is correct |
3 |
Correct |
221 ms |
28120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
243 ms |
27100 KB |
Output is correct |
2 |
Correct |
230 ms |
27344 KB |
Output is correct |
3 |
Correct |
257 ms |
29652 KB |
Output is correct |
4 |
Correct |
62 ms |
24340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
25680 KB |
Output is correct |
2 |
Correct |
134 ms |
27768 KB |
Output is correct |
3 |
Correct |
146 ms |
24132 KB |
Output is correct |
4 |
Correct |
242 ms |
28748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
248 ms |
24660 KB |
Output is correct |
2 |
Correct |
279 ms |
27068 KB |
Output is correct |
3 |
Correct |
196 ms |
24924 KB |
Output is correct |
4 |
Correct |
284 ms |
30800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1281 ms |
53468 KB |
Output is correct |
2 |
Correct |
866 ms |
26544 KB |
Output is correct |
3 |
Correct |
698 ms |
24148 KB |
Output is correct |
4 |
Runtime error |
961 ms |
65540 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1180 ms |
50888 KB |
Output is correct |
2 |
Correct |
594 ms |
26316 KB |
Output is correct |
3 |
Correct |
552 ms |
24148 KB |
Output is correct |
4 |
Runtime error |
755 ms |
65536 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |