提出 #75661428


ソースコード 拡げる

#include <bits/stdc++.h>

using namespace std;
using ll=long long;

const int MXN=2e5+1;

ll N,K,A[MXN];

bool check(ll m) {
    ll cnt=0,k=K;
    for(int i=1;i<=N;i++) {
        if(m<=A[i]) continue;
        if(k<(m-A[i]+i-1)/i) return 0;
        k-=(m-A[i]+i-1)/i;
    }
    return 1;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);

    cin>>N>>K;
    for(int i=1;i<=N;i++) cin>>A[i];

    ll l=0,r=2e18;
    while(l<r) {
        ll m=l+(r-l+1)/2;
        if(check(m)) l=m;
        else r=m-1;
    }
    cout<<l;
}

提出情報

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

コンパイルエラー

./Main.cpp: In function 'bool check(ll)':
./Main.cpp:11:8: warning: unused variable 'cnt' [-Wunused-variable]
   11 |     ll cnt=0,k=K;
      |        ^~~

ジャッジ結果

セット名 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 3360 KiB
00_sample_01.txt AC 1 ms 3432 KiB
00_sample_02.txt AC 1 ms 3536 KiB
01_corner_00.txt AC 1 ms 3360 KiB
01_corner_01.txt AC 6 ms 5064 KiB
01_corner_02.txt AC 1 ms 3576 KiB
01_corner_03.txt AC 42 ms 5240 KiB
01_corner_04.txt AC 35 ms 5240 KiB
01_corner_05.txt AC 35 ms 5180 KiB
01_corner_06.txt AC 33 ms 5092 KiB
01_corner_07.txt AC 33 ms 5068 KiB
01_corner_08.txt AC 34 ms 5204 KiB
01_corner_09.txt AC 33 ms 5240 KiB
01_corner_10.txt AC 33 ms 5072 KiB
02_hack_00.txt AC 1 ms 3460 KiB
02_hack_01.txt AC 1 ms 3572 KiB
02_hack_02.txt AC 1 ms 3516 KiB
02_hack_03.txt AC 1 ms 3516 KiB
02_hack_04.txt AC 6 ms 4812 KiB
02_hack_05.txt AC 5 ms 4724 KiB
02_hack_06.txt AC 3 ms 3660 KiB
02_hack_07.txt AC 18 ms 4816 KiB
02_hack_08.txt AC 23 ms 4892 KiB
02_hack_09.txt AC 11 ms 4040 KiB
02_hack_10.txt AC 33 ms 5116 KiB
02_hack_11.txt AC 13 ms 4092 KiB
02_hack_12.txt AC 14 ms 3920 KiB
03_random_00.txt AC 48 ms 5108 KiB
03_random_01.txt AC 47 ms 4924 KiB
03_random_02.txt AC 35 ms 5160 KiB
03_random_03.txt AC 8 ms 3756 KiB
03_random_04.txt AC 46 ms 5180 KiB
03_random_05.txt AC 26 ms 4240 KiB
03_random_06.txt AC 35 ms 5200 KiB
03_random_07.txt AC 2 ms 3664 KiB
03_random_08.txt AC 53 ms 5124 KiB
03_random_09.txt AC 13 ms 3792 KiB
03_random_10.txt AC 20 ms 5244 KiB
03_random_11.txt AC 12 ms 4112 KiB
03_random_12.txt AC 51 ms 5088 KiB
03_random_13.txt AC 29 ms 4368 KiB
03_random_14.txt AC 42 ms 5244 KiB
03_random_15.txt AC 15 ms 4304 KiB
03_random_16.txt AC 42 ms 5072 KiB
03_random_17.txt AC 42 ms 5096 KiB
03_random_18.txt AC 42 ms 5180 KiB
03_random_19.txt AC 42 ms 5072 KiB