report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Subset sum - MarisaOJ: Marisa Online Judge

Subset sum

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ of $n$ integers, your task is to determine whether there exists a subset of $A$ whose sum is equal to $k$. ### Input - The first line contains two integers $n,k$. - The second line contains $n$ integers $A_i$. ### Output - Print YES if there exists a subset of $A$ whose sum is equal to $k; otherwise, print `NO`. ### Constraints - $1 \le n \le 20$. - $1 \le A_i,k \le 10^{18}$. ### Example Input: ``` 4 7 1 2 3 4 ``` Output: ``` YES ```
Backtracking
Binary string
ABC string
Subset sum
Subset
Permutations
Group division
Knight's tour
N-queens problem
Maximum path
Knapsack
Build array
Sudoku
Minesweeper
Travelling Salesman Problem
Word search
Topic
Complete Search
Rating 800
Solution (2) Solution