SUMProblem code: LMDP1104 |
All submissions for this problem are available.
You have N soldiers at your disposal , each having certain strength.Your senior commander is asking some questions.His questions are of the form , given strength S and a number K , do there exist K different soldiers such that sum of their strengths is S.
Input
First line of input contains N and Q.Number of soldiers and the number of queries asked by head commander.Then N lines follow describing the strength of each soldier.After that Q more lines are given each containing S and K as described in the problem.
Output
For each query output a line containing YES or NO accordingly the strength S can be obtained using K soldiers.
Constrains:
1<=N<=100Strength of each soldier is between 1 and 1000 inclusive.
1<=Q<=1000
1<=S<=total strength of all soldiers
1<=K< N/2
Example:
Input: 5 6 3 2 4 5 2 4 2 4 1 5 3 5 2 8 2 8 4 Output: YES YES NO YES YES NO
| Author: | saabir |
| Date Added: | 28-09-2011 |
| Time Limit: | 0.5 sec |
| Source Limit: | 50000 Bytes |
| Languages: | C, C99 strict, CPP 4.0.0-8, CPP 4.3.2 |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions
