Submission #1328812


Source Code Expand

#include<iostream>
#include<vector>
using namespace std;
#include<algorithm>

int main(){
	long long int n,a,b;
	cin>>n>>a>>b;
	vector<int> h(n);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	
	long long int hp=0;
	
	sort(h.begin(),h.end(),greater<int>());
	
	long long int l=0;
	long long int r=h[0];
	
	long long int mid=h[0]/2;
	
	for(int i = 0;i<100;i++){
		hp=mid*b;
		long long int hh=0;
		for(int j=0;j<n;j++){
			if((h[j]-hp)>0){
				hh+=(h[j]-hp)/(a-b);
				if((h[j]-hp)%(a-b)!=0)hh+=1;
			}
		}
		if(hh<=mid){
			r=mid;
			mid=(l+r)/2;
		}else{
			l=mid;
			mid=(l+r)/2;
		}
		if((l+r)%2!=0)mid++;
	}
	
	cout<<mid<<endl;
	return 0;
}

Submission Info

Submission Time
Task D - Widespread
User shichinomiya
Language C++14 (GCC 5.4.1)
Score 400
Code Size 680 Byte
Status AC
Exec Time 153 ms
Memory 640 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 52 ms 640 KB
b06 AC 153 ms 640 KB
b07 AC 131 ms 640 KB
b08 AC 60 ms 640 KB
b09 AC 54 ms 640 KB
b10 AC 53 ms 640 KB
b11 AC 57 ms 640 KB
b12 AC 59 ms 640 KB
b13 AC 141 ms 640 KB