Submission #1323651


Source Code Expand

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/


typedef long long ll;
int N, A, B, H[101010];
//---------------------------------------------------------------------------------------------------
bool check(ll x) {
    ll c = 0;
    rep(i, 0, N) {
        ll h = 1LL * H[i] - 1LL * x * B;
        if (h <= 0) continue;
        c += h / A;
        if (h % A) c++;
    }
    return c <= x;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> A >> B;
    A -= B;
    rep(i, 0, N) cin >> H[i];

    int ng = 0, ok = 1010101010;
    while (ng + 1 != ok) {
        int x = (ng + ok) / 2;
        if (check(x)) ok = x;
        else ng = x;
    }
    cout << ok << endl;
}

Submission Info

Submission Time
Task D - Widespread
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1563 Byte
Status AC
Exec Time 42 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 13
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 14 ms 640 KB
b06 AC 42 ms 640 KB
b07 AC 25 ms 640 KB
b08 AC 26 ms 640 KB
b09 AC 15 ms 640 KB
b10 AC 13 ms 640 KB
b11 AC 15 ms 640 KB
b12 AC 16 ms 640 KB
b13 AC 36 ms 640 KB