Pagini recente » Cod sursa (job #1732100) | Cod sursa (job #235933) | Cod sursa (job #1919189) | Cod sursa (job #1098680) | Cod sursa (job #2029674)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("bleach.in");
ofstream fout ("bleach.out");
int main()
{
int i,N,K,a[100],minp=999999999,p,poate=1,test,s=0;
fin>>N>>K;
for(i=1; i<=N; i++)
fin>>a[i];
for(i=1; i<=N; i++)
if(a[i] < minp) minp=a[i];
p=minp;
test=p;
while(s)
{
s=0;
for(i=1; i<=N; i++)
{
if(p>=a[i] && a[i]!=0)
{
p+=a[i];
s+=a[i];
a[i]=0;
}
}
}
fout<<p;
// while (poate)
// {
// poate=0;
// test=p;
// for(i=1;i<=N;i++)
// if(test>=a[i])
// {
// poate=1;
// test+=a[i];
// a[i]=0;
// }
// cout<<p;
// for(i=1;i<=N;i++)
// s+=a[i];
// if(s==0) break;
// else p++;
// }
//-fout<<p;
return 0;
}