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

socks Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

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

socks.txt

Time Limit: 1s, Memory Limit: 32MB

[Problem Description]

Crud! Damian is late for a scouts camp but has yet to pack his socks.
As he likes to wear matching socks, he needs K socks of the same kind.
However, his socks (of N different kinds) are all in a jumble so he decides to just grab a handful of them.

Furthermore, he knows that he has A_i socks of type i.

How many socks does he need to grab to guarantee that he will have at least K socks of one kind?

[Input]

The first line contains two integers, N and K.
The second line contains N space-separated integers, representing the contents of A.

[Output]

A single integer representing the minimum number of socks that Damian has to grab.
If it is not possible for Damian to guarantee at least K socks, output -1 instead.

[Subtasks]

Subtask 1 (30%): 1 ≤ N ≤ 100; 0 ≤ K ≤ A_i ≤ 1000.
Subtask 2 (70%): 1 ≤ N ≤ 100; 0 ≤ A_i ≤ 1000; 0 ≤ K ≤ 1000.
Subtask 3 (0%): Sample Testcase.

[Sample Input]

3 4
5 5 5

[Sample Output]

10

Tags

Math

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1301001s32MBMinimum
2701011s32MBMinimum
3011s32MBMinimum

Judge Compile Command

g++-8 ans.cpp -o socks -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.