Question: Can someone explain why I ' m getting this error. I need to input the values just like this. 4 1 5 3 5 6

Can someone explain why I'm getting this error. I need to input the values just like this.
4
1535679
14
03163
11
0641-864510
16
16-81461045
16
this is the code:
import java.util.;
class Main
static class Pair
int first;
int second;
Pairint first, int second
this.first first;
this.second second;
static Pair getCandidatePairint A int target
HashSet set new HashSet;
for int num : A
int complement target num;
if setcontainscomplement
return new Pairnum complement;
set.addnum;
return new Pair;
public static void mainString args
Scanner scanner new ScannerSystemin;
int t scanner.nextInt;
scanner.nextLine; Consume newline
for int i ; i t; i
String statusAndSize scanner.nextLinesplit;
int status Integer.parseIntstatusAndSize;
int size Integer.parseIntstatusAndSize;
int groceries new intsize;
String groceriesString scanner.nextLinesplit;
for int j ; j size; j
groceriesj Integer.parseIntgroceriesStringj;
int target scanner.nextInt;
scanner.nextLine; Consume newline
Pair pair;
if status
pair getCandidatePairSortedgroceries target;
else
pair getCandidatePairgroceries target;
if pairfirst && pair.second
System.out.printlnTest case # i : Spend target dollars by buying the groceries with Math.minpairfirst, pair.second dollars and Math.maxpairfirst, pair.second dollars.";
else
System.out.printlnTest case # i : No way you can spend exactly target dollars.";
static Pair getCandidatePairSortedint A int target
int left right Alength ;
while left right
int sum Aleft Aright;
if sum target
return new PairAleft Aright;
else if sum target
left;
else
right;
return new Pair;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!