Submission #2205237


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
long long a, b, h[101010], l, r, s[101010],t;
bool ans, q;

bool chk(long long x){
ll u = b*x;
ll ht = a-b;
ll c=0;
for(int i =1; i<=n; i++){
    if(h[i]-u<=0)continue;
    ht = h[i]-u;
    c+=ht/(a-b);
    if(ht%(a-b)!=0)c++;
}
if(c>x)return false;
else return true;
}


int main(){
cin >> n >> a >> b;
for(int i =1 ; i<=n; i++){
    cin >> h[i];
    r = max(h[i], r);
}
l=1;
while(l<=r){
    t=(l+r)/2;
    ans = chk(t);
    q = chk(t-1);
    if(ans==true && q==false)break;
    if(ans)r=t;
    else l=t;
}

cout << t << endl;

return 0;}

Submission Info

Submission Time
Task D - Widespread
User KazukiMH
Language C++14 (GCC 5.4.1)
Score 400
Code Size 656 Byte
Status AC
Exec Time 108 ms
Memory 1024 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 48 ms 1024 KB
b06 AC 108 ms 1024 KB
b07 AC 70 ms 1024 KB
b08 AC 62 ms 1024 KB
b09 AC 48 ms 1024 KB
b10 AC 44 ms 1024 KB
b11 AC 51 ms 1024 KB
b12 AC 50 ms 1024 KB
b13 AC 84 ms 1024 KB