提出 #7439117


ソースコード 拡げる

#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
// 型に合わせた値 2倍してもオーバーフローしないようにする
// const int INF = 1e9;
const LL INF = 1e10;

LL N, A, B;
vector<LL> h;

bool f(LL K){
    LL tmp = 0;
    for(int i=0; i<N; i++){
        LL rem = h[i]-B*K;
        if(rem > 0) tmp += (rem+(A-B-1)) / (A-B);
    }
    return (tmp <= K);
}

LL binary_search(LL ok, LL ng){
    while (abs(ok - ng) > 1) {
        LL mid = (ok + ng) / 2;
        if(f(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    cin >> N >> A >> B;
    h = vector<LL>(N);     // サイズNを確保
    for(int i=0; i<N; i++) cin >> h[i];
    cout << binary_search(INF, 0) << endl;
}

提出情報

提出日時
問題 D - Widespread
ユーザ AokabiC
言語 C++14 (GCC 5.4.1)
得点 400
コード長 806 Byte
結果 AC
実行時間 69 ms
メモリ 1024 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 13
セット名 テストケース
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
ケース名 結果 実行時間 メモリ
a01 AC 1 ms 256 KiB
a02 AC 1 ms 256 KiB
a03 AC 1 ms 256 KiB
b04 AC 1 ms 256 KiB
b05 AC 46 ms 1024 KiB
b06 AC 69 ms 1024 KiB
b07 AC 55 ms 1024 KiB
b08 AC 55 ms 1024 KiB
b09 AC 44 ms 1024 KiB
b10 AC 43 ms 1024 KiB
b11 AC 45 ms 1024 KiB
b12 AC 46 ms 1024 KiB
b13 AC 64 ms 1024 KiB