## GFSSOC '17 J1 - Ramen and Studying

View as PDF

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 31M

Authors:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

While studying after school, Ace always needs Ramen to keep himself energized. For different courses, Ace needs different numbers of bowls of Ramen to be able to study them. For TOK, he needs bowl, for English, , for Chemistry, , and for Math, . Ace always strives to study as many subjects a day as possible, and he only has bowls of Ramen at home. For tonight, Ace has to study for courses. He needs your help to figure out whether or not he has enough bowls or not. If Ace has enough bowls of Ramen, output YEA BOI. If he doesn't, output Go to Metro and the maximum number of courses he can finish with his current supply of Ramen on a new line.

#### Input Specification

Line 1: integers ,

Next lines: Courses Ace must study for (TOK, English, Math, and Chem)

#### Sample Input 1

3 6
Math
TOK
English

#### Sample Output 1

Go to Metro
2

• commented on May 6, 2020, 10:03 a.m.

Out of curiosity why does adding

import sys
input = sys.stdin.readline

Change the output the program gives

#### https://dmoj.ca/submission/2074623

• commented on May 6, 2020, 11:21 a.m.

sys.stdin.readline does not strip the trailing newline, while input does. If you manually strip away the trailing newline, your submission will AC.

• commented on May 4, 2020, 8:40 a.m. edited

[deleted]

• commented on May 5, 2020, 12:19 p.m.

What language are you using? With c++, a simple cin>>c>>n where c, n are declared as ints would suffice. With Java, you can initialize a String[]temp, then read the line using BufferedReader, then use the .split(" ") command which takes the space as a parameter and returns each space-separated character as an element in the array. (temp=br.readLine().split()). You can then parse it into two ints c, n using Integer.parseInt(temp[0]), etc. and solve as required.

Or just use C++ to avoid that trouble :)

• commented on May 6, 2020, 7:39 a.m. edited

[deleted]

• commented on Oct. 14, 2018, 9:55 p.m.

Damn this dude TimothyW553 has the exact same answer as nathanl3.