提出 #75639012


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define pb push_back

template<class T> inline bool chmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline bool chmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int MOD = 1e9 + 7;

void solve() {
    
    ll n,k;cin>>n>>k;
    vector<ll> a(n+1);
    for(int i=0;i<n;i++)cin>>a[i];
    //c lassic binary seach;
    auto check=[&](ll mid)->bool{
        ll ops=0;
        for(int i=0;i<n;i++){
            if(a[i]>=mid)continue;
            ll diff=mid-a[i]    ;
            ll op=(diff+i)/(i+1);
            ops+=op;
            if(ops>k)   return false;
        }
        return 1;

    };
    ll l=*min_element(all(a)),h=2e18;
    ll ans=l;
    while(l<=h){
        ll mid=l+(h-l)/2;
        if(check(mid)){
            l=mid+1;
            ans=mid;
        }else h=mid-1;
    }
    cout<<ans<<'\n';

    
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tt = 1;
    //cin>>tt;
    while (tt--) {
        solve();
    }

    return 0;
}

提出情報

提出日時
問題 D - Raise Minimum
ユーザ lavi3
言語 C++23 (GCC 15.2.0)
得点 400
コード長 1264 Byte
結果 AC
実行時間 53 ms
メモリ 4924 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 47
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_corner_00.txt, 01_corner_01.txt, 01_corner_02.txt, 01_corner_03.txt, 01_corner_04.txt, 01_corner_05.txt, 01_corner_06.txt, 01_corner_07.txt, 01_corner_08.txt, 01_corner_09.txt, 01_corner_10.txt, 02_hack_00.txt, 02_hack_01.txt, 02_hack_02.txt, 02_hack_03.txt, 02_hack_04.txt, 02_hack_05.txt, 02_hack_06.txt, 02_hack_07.txt, 02_hack_08.txt, 02_hack_09.txt, 02_hack_10.txt, 02_hack_11.txt, 02_hack_12.txt, 03_random_00.txt, 03_random_01.txt, 03_random_02.txt, 03_random_03.txt, 03_random_04.txt, 03_random_05.txt, 03_random_06.txt, 03_random_07.txt, 03_random_08.txt, 03_random_09.txt, 03_random_10.txt, 03_random_11.txt, 03_random_12.txt, 03_random_13.txt, 03_random_14.txt, 03_random_15.txt, 03_random_16.txt, 03_random_17.txt, 03_random_18.txt, 03_random_19.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3520 KiB
00_sample_01.txt AC 1 ms 3528 KiB
00_sample_02.txt AC 1 ms 3480 KiB
01_corner_00.txt AC 1 ms 3596 KiB
01_corner_01.txt AC 6 ms 4892 KiB
01_corner_02.txt AC 1 ms 3456 KiB
01_corner_03.txt AC 42 ms 4756 KiB
01_corner_04.txt AC 35 ms 4908 KiB
01_corner_05.txt AC 36 ms 4776 KiB
01_corner_06.txt AC 34 ms 4920 KiB
01_corner_07.txt AC 35 ms 4836 KiB
01_corner_08.txt AC 34 ms 4912 KiB
01_corner_09.txt AC 34 ms 4920 KiB
01_corner_10.txt AC 34 ms 4756 KiB
02_hack_00.txt AC 1 ms 3532 KiB
02_hack_01.txt AC 1 ms 3456 KiB
02_hack_02.txt AC 1 ms 3456 KiB
02_hack_03.txt AC 1 ms 3408 KiB
02_hack_04.txt AC 5 ms 4592 KiB
02_hack_05.txt AC 5 ms 4652 KiB
02_hack_06.txt AC 3 ms 3644 KiB
02_hack_07.txt AC 19 ms 4536 KiB
02_hack_08.txt AC 24 ms 4784 KiB
02_hack_09.txt AC 11 ms 3792 KiB
02_hack_10.txt AC 34 ms 4648 KiB
02_hack_11.txt AC 13 ms 3884 KiB
02_hack_12.txt AC 15 ms 3720 KiB
03_random_00.txt AC 48 ms 4908 KiB
03_random_01.txt AC 48 ms 4792 KiB
03_random_02.txt AC 35 ms 4908 KiB
03_random_03.txt AC 8 ms 3644 KiB
03_random_04.txt AC 48 ms 4900 KiB
03_random_05.txt AC 27 ms 3988 KiB
03_random_06.txt AC 35 ms 4816 KiB
03_random_07.txt AC 2 ms 3572 KiB
03_random_08.txt AC 53 ms 4924 KiB
03_random_09.txt AC 13 ms 3640 KiB
03_random_10.txt AC 21 ms 4884 KiB
03_random_11.txt AC 12 ms 3796 KiB
03_random_12.txt AC 52 ms 4840 KiB
03_random_13.txt AC 29 ms 4072 KiB
03_random_14.txt AC 42 ms 4816 KiB
03_random_15.txt AC 16 ms 4080 KiB
03_random_16.txt AC 43 ms 4872 KiB
03_random_17.txt AC 42 ms 4848 KiB
03_random_18.txt AC 42 ms 4884 KiB
03_random_19.txt AC 43 ms 4892 KiB