Submission #4036434


Source Code Expand

#include <bits/stdc++.h>
#define int LL
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
const int MAX_N=100005;
int n,A,B;
int h[MAX_N];
bool check(int k)
{
	int lazy=k*B;
	int res=0;
	rep(i,0,n)res+=ceil(1.0*(h[i]-lazy>0?h[i]-lazy:0)/(A-B));
	return res<=k;
}
signed main()
{
	cin>>n>>A>>B;
	rep(i,0,n)cin>>h[i];
	int lb=1,ub=INF;
	while(lb<ub)
	{
		int mid=(lb+ub)/2;
	//	cout<<mid<<endl;
		if(check(mid))ub=mid;
		else lb=mid+1;
	}
	cout<<lb<<endl;
	return 0;
}


Submission Info

Submission Time
Task D - Widespread
User We_R_Young
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1737 Byte
Status AC
Exec Time 56 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 55 ms 1024 KB
b06 AC 55 ms 1024 KB
b07 AC 56 ms 1024 KB
b08 AC 56 ms 1024 KB
b09 AC 52 ms 1024 KB
b10 AC 52 ms 1024 KB
b11 AC 52 ms 1024 KB
b12 AC 52 ms 1024 KB
b13 AC 53 ms 1024 KB