Time Penalty Unlike a usual CodeChef Starters cont...

बनाया गया: 12 फ़रवरी 2025

का उपयोग करके उत्तर दिया गया O1 द्वारा Chat01

प्रश्न

Time Penalty
Unlike a usual CodeChef Starters contest, Starters 173 has a time penalty for every wrong submission.

You are participating in CodeChef Starters 173, which has a time penalty of
10
10 minutes for every incorrect submission you make.
That is, the total penalty for a problem equals the number of minutes from the start of the contest till your submission receives the AC verdict, plus
10
10 minutes for every incorrect submission made before that.

You solved a problem
X
X minutes after the start of the contest, and made
Y
Y incorrect submissions while doing so.
What's the total time penalty for this problem?

Input Format
The first and only line of input will contain two space-separated integers
X
X and
Y
Y — the number of minutes after which you solved the problem, and the number of wrong submissions you made.
Output Format
Output a single integer: the total time penalty for the problem.

Constraints
1

X

150
1≤X≤150
0

Y

10
0≤Y≤10
Sample 1:
Input
Output
3 2
23
Explanation:
The problem was solved
3
3 minutes after the start of the contest, with
2
2 incorrect submissions.
Since each incorrect submission adds
10
10 minutes to the penalty, the total penalty equals
3
+
2
×
10

23
3+2×10=23.

Sample 2:
Input
Output
58 0
58
import java.util.;
import java.lang.
;
import java.io.*;

class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here

}

}

विचार

Crafting the solution

I’m piecing together a Java solution to compute a penalty based on time and incorrect submissions, parsing inputs, and calculating X + 10 * Y. Ready to implement the code for standard input and output.

Reasoned for a couple of seconds

उत्तर

Below is a sample Java solution that reads the inputs, computes the total penalty, and prints the result:

java
import java.util.*; import java.lang.*; import java.io.*; class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int X = sc.nextInt(); // Minutes after which the problem was solved int Y = sc.nextInt(); // Number of incorrect submissions // Each wrong submission adds 10 minutes to the penalty int totalPenalty = X + (Y * 10); System.out.println(totalPenalty); } }

Explanation:

  1. We read two integers, X and Y, from standard input.
  2. The total time penalty is computed as X + 10 * Y:
    • X = minutes after which you solved the problem.
    • Y * 10 = penalty time added for the Y incorrect submissions.
  3. Finally, we print the total penalty.

इस प्रश्नोत्तर को साझा करें