Submission #1497648


Source Code Expand

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef unsigned long long LL;

const int maxn = 100009;
LL n, A, B, h[maxn];
LL l = 0, r = 9e18, mid;

bool check(LL x){
	LL res = 0;
	for (LL i=1; i<=n; i++)
		if (h[i] > B*x)
			res += (h[i]-B*x+A-B-1)/(A-B);
	return res <= x;
}

int main(){
	scanf("%llu%llu%llu", &n, &A, &B);
	for (LL i=1; i<=n; i++) scanf("%llu", &h[i]);
	while (l < r){
		mid = (l+r) >> 1;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%llu\n", l);
	return 0;
}

Submission Info

Submission Time
Task D - Widespread
User Cyanic
Language C++14 (GCC 5.4.1)
Score 400
Code Size 552 Byte
Status AC
Exec Time 38 ms
Memory 896 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:20:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%llu%llu%llu", &n, &A, &B);
                                   ^
./Main.cpp:21:46: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for (LL i=1; i<=n; i++) scanf("%llu", &h[i]);
                                              ^

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 128 KB
a02 AC 0 ms 128 KB
a03 AC 1 ms 128 KB
b04 AC 1 ms 128 KB
b05 AC 18 ms 896 KB
b06 AC 38 ms 896 KB
b07 AC 25 ms 896 KB
b08 AC 21 ms 896 KB
b09 AC 18 ms 896 KB
b10 AC 18 ms 896 KB
b11 AC 18 ms 896 KB
b12 AC 19 ms 896 KB
b13 AC 36 ms 896 KB