-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIce.java
More file actions
64 lines (52 loc) · 1.13 KB
/
Ice.java
File metadata and controls
64 lines (52 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.util.ArrayList;
import java.util.*;
public class Ice
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
int cost;
int arr[]=new int[1000];
int n;
ArrayList<Integer> list=new ArrayList<Integer>();
HashMap<Integer, int[]> map
= new HashMap<>();
for(int i=1;i<=t;i++)
{ String label="list1" + Integer.toString(t);
ArrayList<Integer> list1=new ArrayList<Integer>();
cost=sc.nextInt();
n=sc.nextInt();
for(int j=0;j<n;j++)
{
arr[j]=sc.nextInt();
}
for(int j=0;j<n;j++)
{
for(int k=j+1;k<n;k++)
{
if(arr[j]+arr[k]== cost)
{
list.add(j+1);
list.add(k+1);
// System.out.print(j+1);
//System.out.print(" ");
//System.out.print(k+1);
}
}
break;
}
}
try {
for(int i=0;i<t;i++)
{
for (int j=i*2; j<i+2; j++)
{
System.out.print(list.get(j)+" ");
// System.out.println();
}
System.out.println();
}
}catch(Exception e)
{System.out.println();}
}}