답안 #743987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743987 2023-05-18T07:00:43 Z beepbeepsheep Weirdtree (RMI21_weirdtree) C++17
13 / 100
2000 ms 6352 KB
#include "weirdtree.h"
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll,ll>
#define cerr if (0) cerr
using namespace std;
ll n;
vector<ll> v;
void initialise(int N, int Q, int H[]) {
	// Your code here.
	n=N;
	v.emplace_back(0);
	for (int i=1;i<=N;i++){
        v.emplace_back(H[i]);
	}
}
void cut(int l, int r, int k) {
    ll lb=0,rb=1000000000,mb;
    while (lb!=rb-1){
        mb=(lb+rb)>>1;
        ll ans=0;
        for (int i=l;i<=r;i++){
            ans+=max(v[i]-mb,0LL);
        }
        if (ans>=k) lb=mb;
        else rb=mb;
    }
    ll s=l,e=r+2,m;
    while (s!=e-1){
        m=(s+e)>>1;
        ll ans=0;
        for (int i=l;i<m;i++){
            ans+=max(v[i]-lb,0LL);
        }
        for (int i=m;i<=r;i++){
            ans+=max(v[i]-lb-1,0LL);
        }
        if (ans>k) e=m;
        else s=m;
    }
    for (int i=l;i<s;i++){
        v[i]=min(lb,v[i]);
    }
    for (int i=s;i<=r;i++){
        v[i]=min(lb+1,v[i]);
    }
	// Your code here.
}
void magic(int i, int x) {
    v[i]=x;
	// Your code here.
}
long long int inspect(int l, int r) {
	// Your code here.
	ll ans=0;
	for (int i=l;i<=r;i++){
        ans+=v[i];
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Execution timed out 2032 ms 2180 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 388 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 388 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Execution timed out 2076 ms 6352 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2016 ms 6148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Execution timed out 2032 ms 2180 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Execution timed out 2032 ms 2180 KB Time limit exceeded
4 Halted 0 ms 0 KB -