# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
762581 |
2023-06-21T14:10:19 Z |
vjudge1 |
Meteors (POI11_met) |
C++17 |
|
924 ms |
57648 KB |
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <cmath>
#include <queue>
#include <map>
#include <set>
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ent "\n"
const int maxn = 3e5 + 100;
const ll INF = (ll)2e18;
const int inf = (ll)2e9;
const int maxl = 26;
const int MOD = 1e9 + 7;
int n, m, q;
vector<int> g[maxn];
int a[maxn];
int ans[maxn];
int t[maxn];
int l[maxn];
int r[maxn];
int x[maxn];
vector<int> cl;
void upd(int i, int x){
for(; i <= m; i |= (i + 1)) t[i] += x, cl.push_back(i);
}
void upd(int l, int r, int x){
if(l <= r){
upd(l, x); upd(r + 1, -x);
} else{
upd(1, x);
upd(r + 1, -x);
upd(l, x);
}
}
ll get(int i){
ll res = 0;
for(; i > 0; i = (i & (i + 1)) - 1) res += t[i];
return res;
}
void f(int tl, int tr, vector<int> &v){
if(tl > tr) return;
int mid = (tl + tr) >> 1;
vector<int> L, R;
for(int i = tl; i <= mid; i++){
upd(l[i], r[i], x[i]);
}
for(int x: v){
ll sum = 0;
for(int i: g[x]){
sum = min((ll)1e18, 1ll * get(i) + sum);
}
if(a[x] > sum) a[x] -= sum, R.push_back(x);
else ans[x] = mid, L.push_back(x);
}
for(int x: cl) t[x] = 0;
cl.clear();
f(tl, mid - 1, L);
f(mid + 1, tr, R);
}
void test(){
cin >> n >> m;
for(int i = 1; i <= m; i++){
int x; cin >> x;
g[x].push_back(i);
}
vector<int> v;
for(int i = 1; i <= n; i++){
cin >> a[i]; v.push_back(i);
ans[i] = -1;
}
cin >> q;
for(int i = 1; i <= q; i++){
cin >> l[i] >> r[i] >> x[i];
}
f(1, q, v);
for(int i = 1; i <= n; i++){
if(ans[i] == -1) cout << "NIE\n";
else cout << ans[i] << ent;
}
}
int main(){
// freopen("cows.in", "r", stdin);
// freopen("cows.out", "w", stdout);
// ios_base::sync_with_stdio(0);
// cin.tie(0), cout.tie(0);
int t; t = 1;
while(t--) test();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7364 KB |
Output is correct |
2 |
Correct |
5 ms |
7508 KB |
Output is correct |
3 |
Correct |
4 ms |
7364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
7 ms |
7496 KB |
Output is correct |
3 |
Correct |
5 ms |
7500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
11568 KB |
Output is correct |
2 |
Correct |
121 ms |
14904 KB |
Output is correct |
3 |
Correct |
100 ms |
12052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
14076 KB |
Output is correct |
2 |
Correct |
108 ms |
14020 KB |
Output is correct |
3 |
Correct |
127 ms |
14524 KB |
Output is correct |
4 |
Correct |
35 ms |
9472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
13520 KB |
Output is correct |
2 |
Correct |
98 ms |
14580 KB |
Output is correct |
3 |
Correct |
50 ms |
10656 KB |
Output is correct |
4 |
Correct |
101 ms |
12220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
13688 KB |
Output is correct |
2 |
Correct |
111 ms |
14072 KB |
Output is correct |
3 |
Correct |
84 ms |
11716 KB |
Output is correct |
4 |
Correct |
125 ms |
14648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
924 ms |
57648 KB |
Output is correct |
2 |
Incorrect |
653 ms |
53420 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
881 ms |
57172 KB |
Output is correct |
2 |
Incorrect |
609 ms |
51992 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |