-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprob_5735.java
More file actions
53 lines (49 loc) · 1.27 KB
/
prob_5735.java
File metadata and controls
53 lines (49 loc) · 1.27 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
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
//solved
//implement comparator
class Main {
private static class One implements Comparable<One> {
public int d;
public int idx;
public One(int x, int y) {
this.d =x;
this.idx = y;
}
public int compareTo( One a){
return d-a.d;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int Case=0;
while (true) {
Case++;
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
if(n ==l && n==r && n==0) break;
System.out.println("Case "+Case);
ArrayList<One> mList = new ArrayList<One>();
for(int i=1; i<=n; i++) {
One mOne = new One(sc.nextInt(), i);
mList.add(mOne);
}
Collections.sort(mList);
ArrayList<Integer> mL = new ArrayList<Integer>();
for(int i=0; i<l; i++) mL.add(mList.get(i).idx);
Collections.sort(mL);
String out="";
for(int i=0; i<l-1; i++) out += mL.get(i) + " ";
System.out.println(out + mL.get(l-1));
mL.clear();
for(int i=n-r; i<n; i++) mL.add(mList.get(i).idx);
out ="";
Collections.sort(mL); Collections.reverse(mL);
for(int i=0; i<r-1; i++) out +=mL.get(i) + " ";
System.out.println(out + mL.get(r-1));
}
}
}