Submission #1335839


Source Code Expand

#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
typedef long long ll;

long long n, a, b;	ll hp[100001] = { 0 }, h[100001] = { 0 }, coun = 1, ookii = 0, ok = 1000000000, no = 0;

int chec(ll z) {
	for (int i = 0; i < n; i++)
	{
		hp[i] -= b*coun;
		if (hp[i] > 0) {
			ookii += hp[i] / a + !!(hp[i] % a);
			if (ookii > coun) {
				break;
			}
		}
	}
	if (ookii <= coun) {
		ok = coun;
	}
	else {
		no = coun;
	}
	return coun;
}

int main()
{
	cin >> n >> a >> b;
	a = a - b;

	REP(i, n) {
		cin >> h[i];
	}

	while (1) {
		REP(i, 100001) { hp[i] = h[i]; }
		ookii = 0;
		coun = (no + ok) / 2;
		if (ok - no < 2) {
			cout << ok << endl; break;
		}
		chec(coun);
	}
	return 0;
}

Submission Info

Submission Time
Task D - Widespread
User keidaroo
Language C++14 (GCC 5.4.1)
Score 400
Code Size 833 Byte
Status AC
Exec Time 68 ms
Memory 1792 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 3 ms 1024 KB
a02 AC 3 ms 1024 KB
a03 AC 3 ms 1024 KB
b04 AC 3 ms 1024 KB
b05 AC 48 ms 1792 KB
b06 AC 64 ms 1792 KB
b07 AC 60 ms 1792 KB
b08 AC 56 ms 1792 KB
b09 AC 44 ms 1792 KB
b10 AC 45 ms 1792 KB
b11 AC 46 ms 1792 KB
b12 AC 47 ms 1792 KB
b13 AC 68 ms 1792 KB