# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
466713 |
2021-08-20T13:41:02 Z |
Urvuk3 |
Watering can (POI13_kon) |
C++17 |
|
577 ms |
21496 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=3e5+5,MAXM=40,INF=1e9,MOD=1e9+7;
#define fi first
#define se second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mid (l+r)/2
#define sz(a) int((a).size())
#define all(a) a.begin(),a.end()
#define mod 1000000007LL
#define pb push_back
#define endl "\n"
#define PRINT(x) cerr<<#x<<'-'<<x<<endl<<flush;
#define PRINTBITS(x) {bitset<5> f=x; cerr<<#x<<'-'<<f<<endl<<flush;}
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
ll N,m,K,q,x,y,z,res=0,l,r;
string s,t;
vector<int> a;
int lazy[4*MAXN];
pii seg[4*MAXN]; // cuvacu par gde je druga vrdnost index maximuma
int drvece[4*MAXN];
void propagate(int node,int l,int r){
seg[node].fi+=lazy[node];
if(l<r){
lazy[2*node]+=lazy[node];
lazy[2*node+1]+=lazy[node];
}
lazy[node]=0;
}
void update(int node,int l,int r,int L,int R,int val){
propagate(node,l,r);
if(l>r || l>R || r<L) return;
if(L<=l && r<=R){
lazy[node]+=val;
propagate(node,l,r);
return;
}
update(2*node,l,mid,L,R,val);
update(2*node+1,mid+1,r,L,R,val);
seg[node]=max(seg[2*node],seg[2*node+1]);
}
pii query(int node,int l,int r,int L,int R){
propagate(node,l,r);
if(l>r || l>R || r<L) return {-INF,-INF};
if(L<=l && r<=R) return seg[node];
return max(query(2*node,l,mid,L,R),query(2*node+1,mid+1,r,L,R));
}
void updateDrvece(int node,int l,int r,int idx){
if(l==r){
drvece[node]++;
return;
}
if(idx<=mid) updateDrvece(2*node,l,mid,idx);
else updateDrvece(2*node+1,mid+1,r,idx);
drvece[node]=drvece[2*node]+drvece[2*node+1];
}
int queryDrvece(int node,int l,int r,int L,int R){
if(L<=l && r<=R) return drvece[node];
int ret=0;
if(L<=mid) ret+=queryDrvece(2*node,l,mid,L,R);
if(R>mid) ret+=queryDrvece(2*node+1,mid+1,r,L,R);
return ret;
}
void init(int node,int l,int r){
if(l==r){
if(a[l]>=K){
seg[node]={-INF,-INF};
updateDrvece(1,1,N,l);
}
else{
seg[node]={a[l],l};
}
return;
}
init(2*node,l,mid); init(2*node+1,mid+1,r);
seg[node]=max(seg[2*node],seg[2*node+1]);
}
void inicjuj(int n, int k, int *D){
K=k;
N=n;
a.pb(INF);
for(int i=1;i<=N;i++){
a.pb(D[i-1]);
}
init(1,1,N);
}
void podlej(int a, int b){
++a; ++b;
update(1,1,N,a,b,+1);
while(seg[1].fi>=K){
updateDrvece(1,1,N,seg[1].se);
update(1,1,N,seg[1].se,seg[1].se,-INF);
}
}
int dojrzale(int a, int b){
++a; ++b;
return queryDrvece(1,1,N,a,b);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1484 KB |
Output is correct |
2 |
Correct |
1 ms |
1484 KB |
Output is correct |
3 |
Correct |
1 ms |
1484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1612 KB |
Output is correct |
2 |
Correct |
5 ms |
1676 KB |
Output is correct |
3 |
Correct |
1 ms |
1480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
3188 KB |
Output is correct |
2 |
Correct |
53 ms |
3092 KB |
Output is correct |
3 |
Correct |
50 ms |
2912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
4344 KB |
Output is correct |
2 |
Correct |
91 ms |
4160 KB |
Output is correct |
3 |
Correct |
102 ms |
4220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
6564 KB |
Output is correct |
2 |
Correct |
98 ms |
6696 KB |
Output is correct |
3 |
Correct |
124 ms |
4476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
216 ms |
7228 KB |
Output is correct |
2 |
Correct |
146 ms |
7104 KB |
Output is correct |
3 |
Correct |
243 ms |
6588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
249 ms |
7288 KB |
Output is correct |
2 |
Correct |
227 ms |
11024 KB |
Output is correct |
3 |
Correct |
232 ms |
6456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
328 ms |
12072 KB |
Output is correct |
2 |
Correct |
362 ms |
11080 KB |
Output is correct |
3 |
Correct |
494 ms |
11752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
496 ms |
20824 KB |
Output is correct |
2 |
Correct |
377 ms |
21136 KB |
Output is correct |
3 |
Correct |
577 ms |
18108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
448 ms |
20944 KB |
Output is correct |
2 |
Correct |
390 ms |
21496 KB |
Output is correct |
3 |
Correct |
526 ms |
18628 KB |
Output is correct |