| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
不需要用long long#include <cstdio>
#include <algorithm>
#include <math.h>
using namespace std;
const int MAXN=100005;
int n,k;
int x[MAXN];
bool test(int t)
{
int s=0;
for(int i=0;i<n;i++)
{
if(x[i]<=t) continue;
s+=(int)ceil((x[i]-t)*1.0/(k-1));
if(s>t) return false;
}
return true;
}
void inline read(int &x)
{
char ch=getchar();
while(ch<'0'||ch>'9') ch=getchar();
x=0;
while('0'<=ch&&ch<='9')
{
x*=10;
x+=(ch-'0');
}
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
int mx=0;
for(int i=0;i<n;i++)
{
scanf("%d",&x[i]);
//read(x[i]);
mx=max(mx,x[i]);
}
scanf("%d",&k);
//read(k);
if(k==1)
{
printf("%d\n",mx);
}
else
{
int l=0;
int r=0x3f3f3f3f;
while(r-l>1)
{
int mid=(l+r)>>1;
if(test(mid)) r=mid;
else l=mid;
}
printf("%d\n",r);
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator