Repository navigation
Expand file tree
/
Copy pathMain.java
More file actions
68 lines (62 loc) · 2.05 KB
/
Copy pathMain.java
File metadata and controls
68 lines (62 loc) · 2.05 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
65
66
67
68
import java.util.*;
import java.lang.*;
public class Main {
// public static void main(String[] args)
// {
// Scanner sc = new Scanner(System.in);
// while(sc.hasNextInt()) {
//
// int n = sc.nextInt();
// int m = sc.nextInt();
// //0难度 1报酬
// int[][] input = new int[n][2];
// for (int i = 0; i < n; i++) {
// input[i][0] = sc.nextInt();
// input[i][1] = sc.nextInt();
// }
// Arrays.sort(input, (x, y) -> y[1] - x[1]);
//
// int index = 0;
// for (int i = 1; i < n; i++) {
// if (input[i][0] < input[index][0]) {
// index++;
// input[index][0] = input[i][0];
// input[index][1] = input[i][1];
// }
// }
// index++;
// int[] cur = new int[2];
// for (int i = 0; i < m; i++) {
// cur[0] = sc.nextInt();
// int cur_index = Arrays.binarySearch(input, 0, index, cur, (x, y)->(y[0] - x[0]));
// System.out.println(input[cur_index][1]);
// }
//
// }
// }
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextInt()) {
//int n = 5;
//0难度 1报酬
int[][] input = {{1, 100}, {10, 1000}, {1000, 1001}};
Arrays.sort(input, (x, y) -> y[1] - x[1]);
int index = 0;
for (int i = 1; i < input.length; i++) {
if (input[i][0] < input[index][0]) {
index++;
input[index][0] = input[i][0];
input[index][1] = input[i][1];
}
}
index++;
int[] cur = new int[2];
for (int i = 0; i < 5; i++) {
cur[0] = sc.nextInt();
int cur_index = Arrays.binarySearch(input, 0, index, cur, (x, y) -> (y[0] - x[0]));
if (cur_index < 0) cur_index = -(cur_index + 1);
System.out.println(input[cur_index][1]);
}
}
}
}