← Back to topics
Topic

z-bankar

A
Asmirasmir

#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
int n,k,tmp,frst=100000,h;
int kol[50005];
vector<int>kov;
memset(kol,-1,50001);
scanf("%d %d",&n,&k);
for (int i=0;i<n;i++)
{
scanf("%d",&tmp);
kol[tmp]=1;
if(tmp<frst)frst=tmp;
kov.push_back(tmp);
}
sort(kov.begin(),kov.end());
for (int i=0;i<kov.size();i++)
{
h=kov[i];
for(int j=h+1;j<=k;j++)
{
if(kol[j-h]==-1)continue;
tmp=kol[j-h]+1;
if (tmp<kol[j] || kol[j]==-1) kol[j]=tmp;
}
}
printf("%d",kol[k]);
scanf("%d",&tmp);
return 0;
}


Imam problema sa zadnjih 8 test case tj. 12,13,14,15,16,17,18,19,20 prvih 11 prodje ovo ostalo WR. Jeli moze da mi neko pomogne da nadjem gresku.

Hvala

English:
I'm having problems with the last 8 cases i get wrong result. The first 11 are ok. Could someone please help me to find the problem.

Thanks
h
halil
Tesko mi je analizirati tvoj kod, ali pogledaj na adresi http://pastebin.com/m5404c053, pa ćeš sam otkriti.
A
Asmirasmir
tnx , rijesio sam ovako malo prije , ali u svakom slucaju je pomoglo.

Hvala
D
Daniel93
keep your posts in english please..