# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
881501 | StefanSebez | Fire (JOI20_ho_t5) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
const int N=2*1e5+50;
int lc[2*N],rc[2*N],root,nc,sum[2*N],lazy1[2*N],lazy2[2*N];
void Update1(int &c,int ss,int se,int qs,int qe)
{
}
int main()
{
int n,q;scanf("%i%i",&n,&q);
int a[n+1];for(int i=1;i<=n;i++) scanf("%i",&a[i]);
int L[n+1]={0},R[n+1];
vector<int>mono;
for(int i=1;i<=n;i++)
{
R[i]=n+1;
while(mono.size() && a[mono.back()]<=a[i])
{
R[mono.back()]=i;
mono.pop_back();
}
if(mono.size()) L[i]=mono.back();
mono.pb(i);
}
//for(int i=1;i<=n;i++) printf("%i %i\n",L[i],R[i]);
vector<pair<int,pair<int,int> > >query;
while(q--)
{
int t,l,r;scanf("%i%i%i",&t,&l,&r);
query.pb({l,{t,0}});
query.pb({r,{t,1}});
}
sort(query.begin(),query.end());
for(int i=1,j=0;i<=n;i++)
{
while(j<query.size() && query[j].fi==i)
{
update 0,1,...,i-L[i]-1
j++;
}
}
return 0;
}