Cod sursa(job #752260)
Utilizator | Data | 28 mai 2012 11:01:56 | |
---|---|---|---|
Problema | Transport | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<fstream>
using namespace std;
long v[16001],t,c,s,k,i,n,max;
int main()
{
ifstream in("transport.in");
ofstream out("transport.out");
in>>n>>k;
for(i=1;i<=n;i++)
{
in>>v[i];
if(v[i]>max)
max=v[i];
}
t=k+1;
while(t>k)
{
t=0;
c=1;
while(c<=n)
{
s=0;
for(i=c;i<=n&&s+v[i]<=max;i++)
s+=v[i];
c=i;
t++;
}
max++;
}
out<<max-1;
return 0;
}