# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
865536 |
2023-10-24T09:36:03 Z |
vjudge1 |
Meteors (POI11_met) |
C++17 |
|
62 ms |
65536 KB |
#pragma GCC optimize("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#include <bits/stdc++.h>
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout);
#define adiyer(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define eb emplace_back
#define elif else if
#define uns unsigned
#define emp empty()
#define S second
#define F first
#define int long long
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < pair < ll, ll > > vpll;
typedef vector < pair < int, int > > vpii;
const int N = 3e5 + 123;
const int mod = 1e9 + 7;
const int mxlg = 30;
const int P = 31;
const int K = 599;
const ll inf = 1e9 + 10;
ll n, m, k;
ll x[N], y[N], a[N], l[N], r[N], t[4 * N], z[4 * N];
void push(ll v, ll l, ll r){
if(z[v] == 0) return;
if(l != r){
z[(v << 1)] += z[v];
z[(v << 1) + 1] += z[v];
}
t[v] += z[v] * (r - l + 1);
z[v] = 0;
}
void upd(ll v, ll l, ll r, ll tl, ll tr, ll x){
push(v, l, r);
if(tr < l || r < tl) return;
if(tl <= l && r <= tr){
z[v] += x;
push(v, l, r);
return;
}
ll m = ((l + r) >> 1);
upd((v << 1), l, m, tl, tr, x);
upd((v << 1) + 1, m + 1, r, tl, tr, x);
t[v] = t[(v << 1)] + t[(v << 1) + 1];
}
ll get(ll v, ll l, ll r, ll pos){
push(v, l, r);
if(l == r) return t[v];
ll m = ((l + r) >> 1);
if(pos <= m) return get((v << 1), l, m, pos);
else return get((v << 1) + 1, m + 1, r, pos);
}
void output(){
cin >> n >> m;
for(int i = 1; i <= m; i++) cin >> x[i];
for(int i = 1; i <= n; i++) cin >> y[i];
cin >> k;
ll ans[k + 2][n + 2] = {};
for(int i = 1; i <= k; i++){
cin >> l[i] >> r[i] >> a[i];
if(l[i] <= r[i]){
upd(1LL, 1LL, m, l[i], r[i], a[i]);
}
else{
upd(1LL, 1LL, m, l[i], m, a[i]);
upd(1LL, 1LL, m, 1LL, r[i], a[i]);
}
for(int j = 1; j <= m; j++) ans[i][x[j]] += get(1LL, 1LL, m, j);
}
for(int i = 1; i <= n; i++){
ll tl = 0, tr = k + 1;
while(tr - tl > 1){
ll tm = ((tl + tr) >> 1);
if(ans[tm][i] >= y[i]) tr = tm;
else tl = tm;
}
if(tr == k + 1) cout << "NIE\n";
else cout << tr << '\n';
}
}
const bool cases = 0;
signed main(){
// file("disrupt");
adiyer();
int tt = 1;
if(cases) cin >> tt;
for(int i = 1; i <= tt; i++){
// cout << "Case " << i << ":\n";
output();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
13912 KB |
Output is correct |
2 |
Correct |
45 ms |
16728 KB |
Output is correct |
3 |
Correct |
44 ms |
14428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
15448 KB |
Output is correct |
2 |
Correct |
41 ms |
15192 KB |
Output is correct |
3 |
Correct |
47 ms |
18660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
37 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
38 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
54 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
37 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
62 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
57 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |