Submission #1864679


Source Code Expand

#include <cstdio>
typedef long long ll;
int n, a, b, l, r=1e9, m, h[100005];

bool f(int p) {
	ll i, c=0;
	for(i=0; i<n; i++)
		c += h[i]>(ll)p*b ? (h[i]-p*b+a-1)/a : 0;
	return c<=p;
}

int main() {
	scanf("%d%d%d", &n, &a, &b);
	a -= b;
	for(int i=0; i<n; i++) scanf("%d", &h[i]);
	while(l<r) {
		m = (l+r) / 2;
		if(f(m)) r = m;
		else l = m+1;
	}
	printf("%d", r);
	return 0;
}

Submission Info

Submission Time
Task D - Widespread
User t1234
Language C++14 (GCC 5.4.1)
Score 400
Code Size 403 Byte
Status AC
Exec Time 22 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &a, &b);
                             ^
./Main.cpp:15:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<n; i++) scanf("%d", &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 0 ms 128 KB
a02 AC 1 ms 128 KB
a03 AC 0 ms 128 KB
b04 AC 1 ms 128 KB
b05 AC 14 ms 512 KB
b06 AC 22 ms 512 KB
b07 AC 17 ms 512 KB
b08 AC 17 ms 512 KB
b09 AC 15 ms 512 KB
b10 AC 14 ms 512 KB
b11 AC 15 ms 512 KB
b12 AC 16 ms 512 KB
b13 AC 20 ms 512 KB