Pagini recente » Cod sursa (job #1659216) | Cod sursa (job #2429060) | Cod sursa (job #1524975) | Cod sursa (job #686806) | Cod sursa (job #1027784)
#include <fstream.h>
int i,n,k,kl,km, max;
struct nod{ int x; nod* y;};
nod a,c;
a=new nod; c=new nod; a.y=0;
void cit(){
ifstream fin("transport.in");
fin>>n>>kl;
fin>>max; a.x=max;
for(i=2;i<=n;i++){
c.y=a;
fin>>c.x;
if(c.x>max)
max=c.x;
a=c;
}
fin.close();
}
int trans(){
int i=1;
km=0;
k=max-1; //max curent
do {
k++;
c=a;
km=0; //nr drumuri
q=0; //cantitate curenta in camion
while (c.y!=0){
q=+c.x;
if(km=k) c=c.y;
if(km<k)
c=c.y;
else {
q=0; km++;
}
}
}while(k>kl);
return k;
}
void write(int x){
ofstream fout("transport.out");
fout<<x;
fout.close();
}
int main(){
cit();
write(trans());
return 0;
}