My issue
I am getting a run time error as follows, please help:)
Exception in thread “main” java.util.InputMismatchException: For input string: “111100110101100000101100011111”
at java.base/java.util.Scanner.nextInt(Scanner.java:2264)
at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
at Codechef.main(Main.java:17)
My code
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
int t;
Scanner sc=new Scanner(System.in);
t=sc.nextInt();
for(int i=0;i<t;i++){
int x=sc.nextInt();
int y=sc.nextInt();
String s=sc.nextLine();
int curr_streak=0,long_streak=0,work_days=0,salary;
for(int j=0;j<s.length();j++){
if(s.charAt(j)=='1'){
curr_streak++;
work_days++;
}
else{
if(curr_streak>long_streak) long_streak=curr_streak;
curr_streak=0;
}
}
salary=(x*work_days)+(y*long_streak);
System.out.println(salary);
}
}
}
Problem Link: HCAGMAM1 Problem - CodeChef