I created an if statement that produces the proper output, but I am having trouble turning this solution into a function with standard inputs. In my solution, I am assigning input values, which I assume is not allowed and is the reason it is rejected every time.
The problem with RS studio is that this requires input from stdin and you are probably not providing any input. hence the freezing. As for the wrong answer i have only provided the code to accept input and not altered your logic in any way.
Try your code here Online R Compiler - rscript
and dont forget to enter input in the STDIN tab before executing!
When you say input in STDIN, are you referring to the:
con=file(“stdin”,“r”)
should be:
con=file("30, 120.00", "r")
Ultimately, I want to see what the correct acceptable solution looks like so I can implement that in future questions. This is my first attempt using R as a functional programming language for CodeForces.
no you are not supposed to set the variables like that. Value of balance and withdrawal will keep changing so you need to read the input from “stdin” and set the values accordingly.
And if language is not an issue that i would suggest to use faster languages like C++ or JAVA.
This is so frustrating. I can’t imagine how anyone successfully uses R with CodeForces. Which sucks because that is the language I am interested in. Coupled with the fact I am new to programming.
it is possible but since readLine() reads the whole line at once the second readline() will have nothing to read when submiting. Note that on codeforces the input both balance and withdrawal is given in single line. So you will have to use readline only once and then parse int to get the two number from it… all these will take time and might cause you answer to TLE.
R is not optimized for competitive programming at all so you will face a lot of problems ahead. Since you are new maybe start with python and then move to C++ or Java to really get the feel of how awesome algorithms and data structures are!