# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
922966 |
2024-02-06T11:17:12 Z |
vjudge1 |
Meteors (POI11_met) |
C++17 |
|
4172 ms |
65536 KB |
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define int long long
const int dx[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dy[] = {1, 0, -1, 0, -1, 1, -1, 1};
const int maxn = 3e5+7;
const int inf = 1e9;
const int mod = 1e9+7;
using namespace std;
int n, m, k;
int s[maxn], need[maxn], ans[maxn];
int ql[maxn], qr[maxn], qx[maxn];
vector<int> cur[maxn], g[maxn];
int t[4 * maxn], p[4 * maxn];
struct node{
int l, r;
} d[maxn];
void push(int tl, int tr, int v){
if(tl != tr){
p[v * 2] += p[v];
p[v * 2 + 1] += p[v];
p[v * 2] = min(p[v * 2], (int)1e9);
p[v * 2 + 1] = min(p[v * 2 + 1], (int)1e9);
}
t[v] += p[v];
t[v] = min(t[v], (int)1e9);
p[v] = 0;
}
void build(int tl = 1, int tr = maxn, int v = 1){
t[v] = p[v] = 0;
if(tl == tr) return;
int md = (tl + tr) / 2;
build(tl, md, v * 2);
build(md + 1, tr, v * 2 + 1);
}
void update(int l, int r, int val, int tl = 1, int tr = maxn, int v = 1){
push(tl, tr, v);
if(l > tr || tl > r) return;
if(l <= tl && tr <= r){
p[v] += val;
p[v] = min(p[v], (int)1e9);
push(tl, tr, v);
return;
}
int md = (tl + tr) / 2;
update(l, r, val, tl, md, v * 2);
update(l, r, val, md + 1, tr, v * 2 + 1);
}
int get(int pos, int tl = 1, int tr = maxn, int v = 1){
push(tl, tr, v);
if(tl == tr){
return t[v];
}else{
int md = (tl + tr) / 2;
if(pos <= md){
return get(pos, tl, md, v * 2);
}else{
return get(pos, md + 1, tr, v * 2 + 1);
}
}
}
void solve(){
cin >> n >> m;
for(int i = 1; i <= m; i++){
cin >> s[i];
g[s[i]].push_back(i);
}
for(int i = 1; i <= n; i++) cin >> need[i];
cin >> k;
for(int i = 1; i <= n; i++) d[i] = {1, k};
for(int i = 1; i <= k; i++) cin >> ql[i] >> qr[i] >> qx[i];
for(int rep = 1; rep <= 25; rep++){
for(int i = 1; i <= n; i++){
int mid = (d[i].l + d[i].r) / 2;
cur[mid].pb(i);
}
build();
for(int mid = 1; mid <= k; mid++){
if(ql[mid] <= qr[mid]){
update(ql[mid], qr[mid], qx[mid]);
}else{
update(ql[mid], m, qx[mid]);
update(1ll, qr[mid], qx[mid]);
}
if(!cur[mid].size()) continue;
for(auto x : cur[mid]){
if(d[x].l > d[x].r || d[x].l > mid || d[x].r < mid) continue;
int sum = 0;
for(auto pos : g[x]){
sum += get(pos);
}
if(sum >= need[x]){
ans[x] = mid;
d[x].r = mid - 1;
}else{
d[x].l = mid + 1;
}
}
}
for(int i = 1; i <= k; i++){
cur[i].clear();
}
}
for(int i = 1; i <= n; i++){
if(ans[i] == 0) cout << "NIE\n";
else cout << ans[i] << '\n';
}
}
signed main(){
speed
int test = 1;
// cin >> test;
while(test--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
45656 KB |
Output is correct |
2 |
Correct |
49 ms |
45660 KB |
Output is correct |
3 |
Correct |
48 ms |
45404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
45680 KB |
Output is correct |
2 |
Correct |
48 ms |
45660 KB |
Output is correct |
3 |
Correct |
50 ms |
45728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
727 ms |
49144 KB |
Output is correct |
2 |
Correct |
919 ms |
53972 KB |
Output is correct |
3 |
Correct |
799 ms |
53228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
894 ms |
50560 KB |
Output is correct |
2 |
Correct |
847 ms |
50284 KB |
Output is correct |
3 |
Correct |
922 ms |
54384 KB |
Output is correct |
4 |
Correct |
163 ms |
52564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
405 ms |
49540 KB |
Output is correct |
2 |
Correct |
635 ms |
54800 KB |
Output is correct |
3 |
Correct |
574 ms |
45700 KB |
Output is correct |
4 |
Correct |
794 ms |
53856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
876 ms |
48444 KB |
Output is correct |
2 |
Correct |
813 ms |
50384 KB |
Output is correct |
3 |
Correct |
755 ms |
48872 KB |
Output is correct |
4 |
Correct |
877 ms |
55576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3421 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4172 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |