# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
865095 |
2023-10-24T05:30:54 Z |
vjudge1 |
Meteors (POI11_met) |
C++17 |
|
128 ms |
65536 KB |
// Bolatulu
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
// #define int long long
#define kanagattandirilmagandiktarinizdan ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define F first
#define S second
#define md (tl+tr)/2
#define TL v+v,tl,mid
#define TR v+v+1,mid+1,tr
#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
using namespace std;
int binpow(int a,int n,int M) {
if (n==0)
return 1;
if (n%2!=0)
return (a * binpow(a,n-1,M))%M;
int z=binpow(a,n/2,M);
return (z*z)%M;
}
const ll INF = 1e18;
const int N = 3e5+7;
const int M = 1e9+7;
const ll HZ = 1e5;
const int MAX = INT_MAX;
const int MIN = INT_MIN;
const db pi = 3.141592653;
const int P=31;
struct DO{int l;int r;int sum;};
int n,m,a[N],p[N],q,sz=1,root[N];
DO t[40*N];
vector <int> d[N];
void build(int v=1,int tl=1,int tr=m) {
if (tl==tr)
return;
t[v].l=++sz,t[v].r=++sz;
build(t[v].l,tl,md), build(t[v].r,md+1,tr);
}
int upd(int v,int l,int r,int val,int tl=1,int tr=m) {
if (tl>r or tr<l)
return v;
int nv=++sz;
t[nv]=t[v];
if (tl>=l and tr<=r) {
t[nv].sum+=val;
t[nv].sum=min(t[nv].sum,(int)1e9);
return nv;
}
t[nv].l=upd(t[v].l,l,r,val,tl,md), t[nv].r=upd(t[v].r,l,r,val,md+1,tr);
return nv;
}
int get(int v,int pos,int tl=1,int tr=m,int sum=0) {
sum+=t[v].sum;
sum=min(sum,(int)1e9);
if (tl==tr)
return sum;
if (pos<=md)
return get(t[v].l,pos,tl,md,sum);
else
return get(t[v].r,pos,md+1,tr,sum);
}
int calc(int i,int v) {
if (v==0)
return 0;
int sum=0;
for (auto now : d[i])
sum+=get(root[v],now), sum=min(sum,(int)1e9);
return sum;
}
int bs(int i) {
int l=-1,r=q+1;
while (l+1<r) {
int mid=(l+r)/2;
if (calc(i,mid)>=p[i])
r=mid;
else
l=mid;
}
return r;
}
void solve() {
cin >> n >> m;
for (int i=1;i<=m;i++)
cin >> a[i], d[a[i]].push_back(i);
build();
root[0]=1;
for (int i=1;i<=n;i++)
cin >> p[i];
cin >> q;
for (int i=1;i<=q;i++) {
int l,r,v;
cin >> l >> r >> v;
if (l>r)
root[i]=upd(root[i-1],l,m,v), root[i]=upd(root[i],1,r,v);
else
root[i]=upd(root[i-1],l,r,v);
}
for (int i=1;i<=n;i++) {
int x=bs(i);
if (x==q+1)
cout << "NIE\n";
else
cout << x << '\n';
}
}
signed main() {
// freopen("lca.in", "r", stdin);
// freopen("lca.out", "w", stdout);
kanagattandirilmagandiktarinizdan
int test = 1, count = 1;
// cin >> test;
while (test--) {
// cout << "Case " << count << ":\n";
solve();
if (test)
// cout << '\n';
count++;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10844 KB |
Output is correct |
2 |
Correct |
3 ms |
10844 KB |
Output is correct |
3 |
Correct |
2 ms |
10844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10844 KB |
Output is correct |
2 |
Correct |
2 ms |
10868 KB |
Output is correct |
3 |
Correct |
3 ms |
10844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
35980 KB |
Output is correct |
2 |
Correct |
88 ms |
38228 KB |
Output is correct |
3 |
Correct |
128 ms |
36336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
35924 KB |
Output is correct |
2 |
Correct |
89 ms |
36156 KB |
Output is correct |
3 |
Correct |
89 ms |
38492 KB |
Output is correct |
4 |
Correct |
34 ms |
13656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
25832 KB |
Output is correct |
2 |
Correct |
66 ms |
34384 KB |
Output is correct |
3 |
Correct |
20 ms |
23132 KB |
Output is correct |
4 |
Correct |
86 ms |
36360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
38068 KB |
Output is correct |
2 |
Correct |
85 ms |
39248 KB |
Output is correct |
3 |
Correct |
64 ms |
37044 KB |
Output is correct |
4 |
Correct |
96 ms |
39760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
108 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
109 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |