# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
13231 | dohyun0324 | 돌 무게 재기 (IZhO11_stones) | C++98 | 72 ms | 8112 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,x,y,t=1,p;
struct data
{
int maxi,mini,ch;
}tree[600010];
void update(int x,int y,int k,int s,int e)
{
if(tree[k].ch)
{
tree[k].maxi+=tree[k].ch; tree[k].mini+=tree[k].ch;
tree[k*2].ch+=tree[k].ch; tree[k*2+1].ch+=tree[k].ch; tree[k].ch=0;
}
if(s<=x && y<=e)
{
tree[k].maxi+=p; tree[k].mini+=p; tree[k*2].ch+=p; tree[k*2+1].ch+=p;
return;
}
if(s>y || e<x) return;
update(x,(x+y)/2,k*2,s,e);
update((x+y)/2+1,y,k*2+1,s,e);
tree[k].maxi=max(tree[k*2].maxi,tree[k*2+1].maxi);
tree[k].mini=min(tree[k*2].mini,tree[k*2+1].mini);
}
int main()
{
int i;
scanf("%d",&n);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |