k = int(input())
a = sorted(list(map(int,input().split())))[::-1]
s = 0
t = 0
l = []
d = []
for i in a:
s+=i
d+=[s]
for j in d:
if k == 0:
print(0)
break
elif j>=k:
print(d.index(j)+1)
break
else:
print(-1)
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,c=0,h,d,e,f=0,sum=0,j,cnt=0,flag=0,k=0,x,l,in1,in2,p1,p2,g,w,m=0,n;
stringstream a1,b1;
vector<string>v;
map<string,string>mp;
cin>>a;
long long aa[12];
for(int i=0;i<12;i++)
{
cin>>aa[i];
}
if(a==0)
{
cout<<0<<endl;
}
else
{
sort(aa,aa+12);
for(int i=11;i>=0;i--)
{
sum=sum+aa[i];
cnt++;
if(sum>=a)
{
flag=1;
break;
}
}
if(flag==0)
{
cout<<-1<<endl;
}
else
{
cout<<cnt<<endl;
}
}
}
165A - Supercentral Point | 1493A - Anti-knapsack |
1493B - Planet Lapituletti | 747B - Mammoth's Genome Decoding |
1591C - Minimize Distance | 1182B - Plus from Picture |
1674B - Dictionary | 1426C - Increase and Copy |
520C - DNA Alignment | 767A - Snacktower |
1365A - Matrix Game | 714B - Filya and Homework |
31A - Worms Evolution | 1691A - Beat The Odds |
433B - Kuriyama Mirai's Stones | 892A - Greed |
32A - Reconnaissance | 1236D - Alice and the Doll |
1207B - Square Filling | 1676D - X-Sum |
1679A - AvtoBus | 1549A - Gregor and Cryptography |
918C - The Monster | 4B - Before an Exam |
545B - Equidistant String | 1244C - The Football Season |
1696B - NIT Destroys the Universe | 1674A - Number Transformation |
1244E - Minimizing Difference | 1688A - Cirno's Perfect Bitmasks Classroom |