Submission #1531561
Source Code Expand
#include<cstdio>
typedef long long ll;
ll h[110000];
int n,a,b;
int check(ll k)
{
ll ret=0;
for(int i=1;i<=n;i++)
{
h[i]-=b*k;
if(h[i]>0) ret+=h[i]%(a-b)==0?h[i]/(a-b):h[i]/(a-b)+1;
h[i]+=b*k;
}
return ret<=k;
}
int main()
{
ll s=0;
scanf("%d%d%d",&n,&a,&b);
for(int i=1;i<=n;i++) scanf("%lld",&h[i]),s=s>h[i]?s:h[i];
ll l=0,r=s/b+(s%b!=0);
while(l<=r)
{
ll mid=(l+r)>>1;
if(check(mid)) r=mid-1;
else l=mid+1;
}
printf("%lld\n",r+1);
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Widespread |
User |
CXY |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
500 Byte |
Status |
AC |
Exec Time |
44 ms |
Memory |
896 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:19:26: 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:20:59: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i=1;i<=n;i++) scanf("%lld",&h[i]),s=s>h[i]?s:h[i];
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
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 |
0 ms |
128 KB |
b04 |
AC |
0 ms |
128 KB |
b05 |
AC |
14 ms |
896 KB |
b06 |
AC |
44 ms |
896 KB |
b07 |
AC |
31 ms |
896 KB |
b08 |
AC |
30 ms |
896 KB |
b09 |
AC |
17 ms |
896 KB |
b10 |
AC |
16 ms |
896 KB |
b11 |
AC |
17 ms |
896 KB |
b12 |
AC |
17 ms |
896 KB |
b13 |
AC |
37 ms |
896 KB |