300780: CF149A. Business trip

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Business trip

题意翻译

## 题目描述 多么令人开心啊!Petya的父母去了一个长达一年的商业旅行并且把这个爱玩的孩子独自留下了。Petya高兴到了极点。他跳上床并扔了一整天的枕头,直到... (这和做题有什么关系,汗) 今天Petya打开橱柜发现了一个吓人的字条。他的父母给他留了家务:他应该给他们最喜爱的花浇一整年的水,每一天,无论早上,下午,还是晚上。“等一下”——Petya想。他明白一个事实,如果他在一年中的第$i$月($1\leq i\leq12$)完成父母的任务,这个花就会生长$a_i$厘米,并且如果他在第$i$月不给花浇水,花在这个月就不会长。他的父母不会相信他给花浇过水了,如果这花生长的严格少于$k$厘米。 帮助Petya选择最少的月数浇花,使得这花能够长得不少于$k$厘米。 ### 输入格式: 第一行正好包含一个整数$k$($0\leq k\leq100$)。下一行包含十二个整数:第$i$个数代表$a_i$($0\leq a_i\leq100$) ### 输出格式: 输出的仅仅一个整数,表示Petya给花浇水的最少月数,使得花生长不少于$k$厘米。如果花一年不能生长$k$厘米,输出$-1$。 ### 说明 让我们考虑第一个样例。在第七个月和第九个月给花浇水。然后花长五厘米。 第二样例Petya的父母会相信他,即使花不生长($k=0$ )。所以,Petya可能根本不浇花。 Translated by @Khassar

题目描述

What joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped on the bed and threw pillows all day long, until... Today Petya opened the cupboard and found a scary note there. His parents had left him with duties: he should water their favourite flower all year, each day, in the morning, in the afternoon and in the evening. "Wait a second!" — thought Petya. He know for a fact that if he fulfills the parents' task in the $ i $ -th ( $ 1<=i<=12 $ ) month of the year, then the flower will grow by $ a_{i} $ centimeters, and if he doesn't water the flower in the $ i $ -th month, then the flower won't grow this month. Petya also knows that try as he might, his parents won't believe that he has been watering the flower if it grows strictly less than by $ k $ centimeters. Help Petya choose the minimum number of months when he will water the flower, given that the flower should grow no less than by $ k $ centimeters.

输入输出格式

输入格式


The first line contains exactly one integer $ k $ ( $ 0<=k<=100 $ ). The next line contains twelve space-separated integers: the $ i $ -th ( $ 1<=i<=12 $ ) number in the line represents $ a_{i} $ ( $ 0<=a_{i}<=100 $ ).

输出格式


Print the only integer — the minimum number of months when Petya has to water the flower so that the flower grows no less than by $ k $ centimeters. If the flower can't grow by $ k $ centimeters in a year, print -1.

输入输出样例

输入样例 #1

5
1 1 1 1 2 2 3 2 2 1 1 1

输出样例 #1

2

输入样例 #2

0
0 0 0 0 0 0 0 1 1 2 3 0

输出样例 #2

0

输入样例 #3

11
1 1 4 1 1 5 1 1 4 1 1 1

输出样例 #3

3

说明

Let's consider the first sample test. There it is enough to water the flower during the seventh and the ninth month. Then the flower grows by exactly five centimeters. In the second sample Petya's parents will believe him even if the flower doesn't grow at all ( $ k=0 $ ). So, it is possible for Petya not to water the flower at all.

Input

题意翻译

## 题目描述 多么令人开心啊!Petya的父母去了一个长达一年的商业旅行并且把这个爱玩的孩子独自留下了。Petya高兴到了极点。他跳上床并扔了一整天的枕头,直到... (这和做题有什么关系,汗) 今天Petya打开橱柜发现了一个吓人的字条。他的父母给他留了家务:他应该给他们最喜爱的花浇一整年的水,每一天,无论早上,下午,还是晚上。“等一下”——Petya想。他明白一个事实,如果他在一年中的第$i$月($1\leq i\leq12$)完成父母的任务,这个花就会生长$a_i$厘米,并且如果他在第$i$月不给花浇水,花在这个月就不会长。他的父母不会相信他给花浇过水了,如果这花生长的严格少于$k$厘米。 帮助Petya选择最少的月数浇花,使得这花能够长得不少于$k$厘米。 ### 输入格式: 第一行正好包含一个整数$k$($0\leq k\leq100$)。下一行包含十二个整数:第$i$个数代表$a_i$($0\leq a_i\leq100$) ### 输出格式: 输出的仅仅一个整数,表示Petya给花浇水的最少月数,使得花生长不少于$k$厘米。如果花一年不能生长$k$厘米,输出$-1$。 ### 说明 让我们考虑第一个样例。在第七个月和第九个月给花浇水。然后花长五厘米。 第二样例Petya的父母会相信他,即使花不生长($k=0$ )。所以,Petya可能根本不浇花。 Translated by @Khassar

加入题单

上一题 下一题 算法标签: