-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIceCreamParlor.java
42 lines (38 loc) · 1.05 KB
/
IceCreamParlor.java
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
import java.util.Scanner;
public class IceCreamParlor
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int k=0 ; k<t ; k++)
{
int m = in.nextInt();
int n = in.nextInt();
int[] Cost = new int[n];
for(int j=0 ; j<n ; j++)
{
Cost[j]=in.nextInt();
}
for (int i = 0; i < n; i++)
{
for (int j = i; j < n; j++)
{
if (i == j)
continue;
else
{
if (Cost[i] + Cost[j] > m)
continue;
else
if (Cost[i] + Cost[j] == m)
{
System.out.println((i+1) + " " + (j+1));
}
}
}
}
}
in.close();
}
}