답안 #871072

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871072 2023-11-09T20:09:26 Z Ahmed57 Weirdtree (RMI21_weirdtree) C++17
13 / 100
7 ms 6236 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
long long arr[10001],n;
void initialise(int32_t N, int32_t Q,int32_t h[]){
    n = N;
    for(int i = 1;i<=n;i++){
        arr[i] = h[i];
    }
}
void cut(int32_t l, int32_t r, int32_t k){
    vector<int> v;
    for(int i = l;i<=r;i++){
        v.push_back(arr[i]);
    }
    sort(v.begin(),v.end());
    vector<int> xd;
    int all = 0;
    for(int i = v.size()-1;i>=0;i--){
        all+=v[i];
        xd.push_back(all);
    }
    reverse(xd.begin(),xd.end());
    int nah = 0;
    for(int i = v.size()-1;i>=0;i--){
        if(i&&v[i]==v[i-1])continue;
        int elem = v.size()-i;
        if(k-(xd[i]-(elem*v[i]))>=0){
            nah = i;
        }
    }
    int elem = v.size()-nah;
    long long num = v[nah]-((k-(xd[nah]-(elem*v[nah])))/elem);
    num = max(num,0ll);
    long long rem = k-(xd[nah]-(num*elem));
    for(int i = l;i<=r;i++){
        arr[i] = min(arr[i],num);
        if(arr[i]==num&&rem&&arr[i]!=0){
            arr[i]--;
            rem--;
        }
    }
}
void magic(int32_t i, int32_t x){
    arr[i] = x;
}
long long inspect(int32_t l, int32_t r){
    long long sum = 0;
    for(int i = l;i<=r;i++){
        sum+=arr[i];
    }
    return sum;
}
/*
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    initialise(6,1,{0,1,2,3,1,2,3});
    cut(1,6,3);
    cout<<inspect(1,6)<<endl;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Runtime error 2 ms 2372 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 348 KB Output is correct
2 Correct 3 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 348 KB Output is correct
2 Correct 3 ms 560 KB Output is correct
3 Runtime error 7 ms 6236 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 3164 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Runtime error 2 ms 2372 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Runtime error 2 ms 2372 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -