#include "wall.h"
#include <bits/stdc++.h>
#define mid (l+r)/2
using std::max;
const int N=2e6+55;
long long lazy[N*4];
void propagate(int l , int r , int node)
{
lazy[node]=max(lazy[node],(long long)0);
if(lazy[node]==0)
return ;
if(l!=r)
{
lazy[node*2]+=lazy[node];
lazy[node*2+1]+=lazy[node];
}
lazy[node]=0;
}
void update(int l , int r , int node , int x , int y , int val)
{
propagate(l,r,node);
if(r<x||l>y)
return ;
if(x<=l&&r<=y)
{
lazy[node]+=val;
propagate(l,r,node);
return ;
}
update(l,mid,node*2,x,y,val);
update(mid+1,r,node*2+1,x,y,val);
}
int query(int l , int r , int node , int ind)
{
propagate(l,r,node);
if(l==r&&l==ind)
return lazy[node];
if(ind<=mid)
return query(l,mid,node*2,ind);
else
return query(mid+1,r,node*2+1,ind);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
for(int i=0;i<k;i++)
{
if(op[i]==2)
height[i]*=-1;
update(0,n-1,1,right[i],left[i],height[i]);
}
for(int i=0;i<n;i++)
finalHeight[i]=query(0,n-1,1,i);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |