File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+
3+ import java.util.* ;
4+ import java.io.* ;
5+
6+ class Main {
7+
8+ // IO field
9+ static BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
10+ static BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System . out));
11+ static StringTokenizer st = new StringTokenizer (" " );
12+
13+ static void nextLine () throws Exception {st = new StringTokenizer (br .readLine ());}
14+ static String nextToken() throws Exception {
15+ if (! st. hasMoreTokens()) nextLine();
16+ return st. nextToken();
17+ }
18+ static int nextInt() throws Exception { return Integer . parseInt(nextToken()); }
19+ static long nextLong() throws Exception { return Long . parseLong(nextToken()); }
20+ static double nextDouble() throws Exception { return Double . parseDouble(nextToken()); }
21+ static void bwEnd() throws Exception {bw. flush();bw. close();}
22+
23+ // Additional field
24+
25+ static int N ;
26+ static int [][] A ;
27+
28+ public static void main(String [] args) throws Exception {
29+
30+ ready();
31+ solve();
32+
33+ bwEnd();
34+
35+ }
36+
37+ static void ready() throws Exception {
38+
39+ N = nextInt();
40+ A = new int [N ][3 ];
41+ for (int i= 0 ;i< N ;i++ ) {
42+ A [i][0 ] = nextInt();
43+ A [i][1 ] = nextInt();
44+ A [i][2 ] = i+ 1 ;
45+ }
46+
47+ }
48+
49+ static void solve() throws Exception {
50+
51+ Arrays . sort(A , (a,b) - > {
52+ int resA = (10000 - a[1 ])* a[0 ] + (a[0 ]+ b[0 ])* a[1 ];
53+ int resB = (10000 - b[1 ])* b[0 ] + (a[0 ]+ b[0 ])* b[1 ];
54+ if (resA > resB) return - 1 ;
55+ if (resA < resB) return 1 ;
56+ return a[2 ]- b[2 ];
57+ });
58+ for (int [] i: A ) bw. write(i[2 ] + " " );
59+
60+ }
61+
62+ }
63+
64+ ```
You can’t perform that action at this time.
0 commit comments