oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

superlongnoodles Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

superlongnoodles.html

With a bit of thinking, all the bunnies were snuggled as close to the mud as possible. Happy and contented, they all went home, except for one especially short and fluffy bunny. This bunny began laughing maniacally and said to Po.

"Hahaha, that was fun. My name is Tu Zi. Oh, here's the Dragon Scroll you wanted. Don't worry, I didn't mean any harm and I just wanted to play a game with you. Congratulations for solving all the puzzles I set for you! You did it way faster than I expected! Can I reward you with a bowl of my Awesome Super Long noodles? I know they're nowhere as good as Ping's, but still, they're really not bad."

Quite obviously, Po would like to try those noodles.

"Oh, haha. I just thought of another puzzle! My noodle cutting skills are really awesome, and I have batches of pre-made noodles, each of exactly the same length. But since you're so smart, I want to reward you with the longest noodle ever! However, I must not be able to form this noodle length by joining up the other noodles that I already have. Ha! Take that! Bet you'll take super long to solve this."

Po wants the longest noodle that he can get, but oh no! He's hungry and can't think when he's hungry. To satisfy his extreme hunger, Po must eat noodles that are of at least a certain length. After all, he can't be eating thin slices of noodles, right? Help him out by telling him the noodle length he should ask for.

Input

The first line contains two integers, n and k. n represents the number of batches of noodles Tu Zi has and k represents the minimum length of the noodle that Po wants to eat.
The following line contains n integers, representing the length (1 ≤ length ≤ 1,000) of each noodle in each batch of Tu Zi's noodles.

For all test cases, 1 ≤ n ≤ 10.

Output

Output the maximum noodle length that cannot be made with all the other noodles that Tu Zi has made. If the maximum length is infinite, output -1. If there is no such length that will satisfy Po's growling stomach, output -2.

Sample Input

2 2
2 5

Sample Output

3

Explanation

After 3, all the noodle lengths can be formed with lengths 2 and 5, and 3 satisfies Po's hunger.

Tags

Number Theory, Dijkstra, NOI 2011 Sec Selection Test 2

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1100131s32MBAverage
2011s32MBAverage

Judge Compile Command

g++-8 ans.cpp -o superlongnoodles -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.