답안 #743953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743953 2023-05-18T06:42:29 Z jamezzz Weirdtree (RMI21_weirdtree) C++17
13 / 100
23 ms 10544 KB
#include "weirdtree.h"
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define dbg(...) printf(__VA_ARGS__);
#else
#define dbg(...)
#endif
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define INF 1023456789
typedef long long ll;
typedef pair<int,int> ii;

#define maxn 300005

int n,q,h[maxn];

void initialise(int N,int Q,int H[]){
	n=N,q=Q;
	for(int i=1;i<=n;++i)h[i]=H[i];
}
void cut(int l,int r,int k){
	if(n<=1000&&q<=1000){
		vector<int> v;
		for(int i=l;i<=r;++i)v.pb(h[i]);
		v.pb(0);
		sort(all(v));
		int num=0,mn=v.back(),rem=k;
		while(!v.empty()){
			int x=v.back();
			if((ll)num*(mn-x)<=rem){
				rem-=num*(mn-x);
				++num;
				mn=x;
				v.pop_back();
			}
			else{
				int sub=rem/num;
				mn-=sub;
				rem-=sub*num;
				break;
			}
		}
		int cnt=0;
		for(int i=l;i<=r;++i){
			if(h[i]>=mn){
				if(cnt<rem)h[i]=mn-1;
				else h[i]=mn;
				++cnt;
			}
			h[i]=max(h[i],0);
		}
	}
}
void magic(int i,int x){
	if(n<=1000&&q<=1000){
		h[i]=x;
	}
}
ll inspect(int l,int r){
	if(n<=1000&&q<=1000){
		ll ans=0;
		for(int i=l;i<=r;++i)ans+=h[i];
		return ans;
	}
	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Incorrect 6 ms 3036 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 340 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 340 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Incorrect 23 ms 10544 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 9536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Incorrect 6 ms 3036 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Incorrect 6 ms 3036 KB Output isn't correct
4 Halted 0 ms 0 KB -