Submission #1613379


Source Code Expand

#include <iostream>
#include <math.h>

using namespace std;  
typedef long long LL;

int N, A, B, h[(int)1e5];

bool judge(LL K) {
    LL sum = 0;
    for(int i = 0; i < N; i++) {
        LL t = (LL)h[i]-K*B;
        if (t > 0) {
            sum += (int)ceil(t*1.0/(A-B));
            if(sum > K)
                return false;
        }
    }
    return true;
}

int main()
{
    cin >> N >> A >> B;

    for (int i = 0; i < N; i++)
        scanf("%ld", &h[i]);

    LL low = 0, high = 1e9;

    while (low < high) {
        LL mid = (low + high) / 2;
        if (judge(mid))
            high = mid;
        else
            low = mid+1;
    }

    cout << low << endl;

    return 0;
}

Submission Info

Submission Time
Task D - Widespread
User kira924age
Language C++14 (GCC 5.4.1)
Score 0
Code Size 727 Byte
Status WA
Exec Time 27 ms
Memory 640 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:27:27: warning: format ‘%ld’ expects argument of type ‘long int*’, but argument 2 has type ‘int*’ [-Wformat=]
         scanf("%ld", &h[i]);
                           ^
./Main.cpp:27:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%ld", &h[i]);
                            ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 5
WA × 8
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 WA 26 ms 640 KB
b06 WA 13 ms 640 KB
b07 WA 26 ms 640 KB
b08 AC 27 ms 640 KB
b09 WA 12 ms 640 KB
b10 WA 12 ms 640 KB
b11 WA 15 ms 640 KB
b12 WA 26 ms 640 KB
b13 WA 26 ms 640 KB