Pagini recente » Cod sursa (job #2698015) | Cod sursa (job #2747471) | Cod sursa (job #2191542) | Cod sursa (job #861950) | Cod sursa (job #1027785)
#include<fstream.h>
using namespace std;
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;
}