|
1 |
| - |
2 |
| -/* |
3 |
| -Problem -> Solve History Ranking |
4 |
| -
|
5 |
| -DUMB JERRY |
6 |
| -DUMB JERRY |
7 |
| -
|
8 |
| -Problem Statement |
9 |
| -
|
10 |
| -As usual, Jerry and Tom are fighting. Tom wants to prove that Jerry is Dumb, So he made a problem and asked jerry. |
11 |
| -
|
12 |
| -Given a sequence A of size N, and an operation. |
13 |
| -
|
14 |
| -In one operation you can pick an element either from the front or back of the Sequence and write it down and delete it from the array. |
15 |
| -Jerry has to perform the given operation until sequence A becomes empty. |
16 |
| -
|
17 |
| -Tom wants the written sequence to be lexicographically maximum possible by performing the given operation on sequence A. |
18 |
| -
|
19 |
| -Jerry can’t solve the problem on his own. So you have to help him. |
20 |
| -
|
21 |
| -Note:- |
22 |
| -
|
23 |
| -Sequence X of length N is lexicographically greater than Sequence Y of length N, if there exist such i (1<=i<=N), that Xi >Yi and for any j (1<=j<i) Xi=Yi. |
24 |
| -
|
25 |
| -Constraint |
26 |
| -
|
27 |
| -• 1 <= N <= 105 |
28 |
| -• 0 <= Ai <= 109 |
29 |
| -
|
30 |
| -• All input values are integer. |
31 |
| -
|
32 |
| -Input Format |
33 |
| -
|
34 |
| -• First-line contains N, length of the sequence A |
35 |
| -
|
36 |
| -• Second line contains N space-separated integers denoting the sequence A. |
37 |
| -
|
38 |
| -Output Format |
39 |
| -
|
40 |
| -• In first print the lexicographically maximum sequence made by performing operations on sequence A |
41 |
| -
|
42 |
| -Sample Input 1 |
43 |
| -
|
44 |
| -3 |
45 |
| -
|
46 |
| -3 1 2 |
47 |
| -
|
48 |
| -Sample Output 1 |
49 |
| -
|
50 |
| -3 2 1 |
51 |
| -
|
52 |
| -Explanation of Sample 1 |
53 |
| -
|
54 |
| -For test case1 |
55 |
| -
|
56 |
| -We get sequence {3,1,2} if we |
57 |
| -Pick the element from the front of the sequence (3) and delete it from the original sequence {1,2} |
58 |
| -Pick the element from the front of the sequence (3,1) and delete it from the original sequence {2} |
59 |
| -Pick the element from the front of the sequence (3,1,2) and delete it from the original sequence {} |
60 |
| -We get sequence {3,2,1} if we |
61 |
| -Pick the element from the front of the sequence (3) and delete it from the original sequence {1,2} |
62 |
| -Pick the element from the back of the sequence (3,2) and delete it from the original sequence {1} |
63 |
| -Pick the element from the front of the sequence (3,2,1) and delete it from the original sequence {} |
64 |
| -We get sequence {2,3,1} if we |
65 |
| -Pick the element from the back of the sequence (2) and delete it from the original sequence {3,1} |
66 |
| -Pick the element from the front of the sequence (2,3) and delete it from the original sequence {1} |
67 |
| -Pick the element from the front of the sequence (2,3,1) and delete it from the original sequence {} |
68 |
| -We get sequence {2,1,3} if we |
69 |
| -Pick the element from the back of the sequence (2) and delete it from the original sequence {3,1} |
70 |
| -Pick the element from the back of the sequence (2,1) and delete it from the original sequence {3} |
71 |
| -Pick the element from the front of the sequence (2,1,3) and delete it from the original sequence {} |
72 |
| -Compare to other {3,2,1} is lexicographically largest. |
73 |
| -
|
74 |
| -Things to Note for the Candidate |
75 |
| -
|
76 |
| -You can use your own IDE like Visual Studio Code, Eclipse, or any other IDE that you are comfortable with to build your solution code. |
77 |
| -The IDE provided on the platform is purely for submission. Avoid using the IDE for coding out the solution. |
78 |
| -Test against any custom input in your own IDE. In the IDE provided on the platform, you cannot pass custom test cases and see the output. |
79 |
| -Use standard input and standard output in your program for the IDE to run the test cases smoothly against your code. We are giving a sample problem statement along with a solution that will pass the test cases in the IDE. - Sample Problem Statement (Right Click and Open in New Tab to view.) |
80 |
| -
|
81 |
| -
|
82 |
| -
|
83 |
| - */ |
84 |
| - |
85 |
| - |
86 |
| -/* package whatever; // don't place package name! */ |
87 |
| - |
88 |
| -import java.util.*; |
89 |
| -import java.lang.*; |
90 |
| -import java.io.*; |
91 |
| - |
92 |
| -/* Name of the class has to be "Main" only if the class is public. */ |
93 |
| -class Relevel_Test |
94 |
| -{ |
95 |
| - |
96 |
| - public static void main (String[] args) throws java.lang.Exception |
97 |
| - { |
98 |
| - // your code goes here |
99 |
| - Scanner sc = new Scanner(System.in); |
100 |
| - int m = sc.nextInt(); |
101 |
| - int n = sc.nextInt(); |
102 |
| - |
103 |
| - int[] x = new int[m]; |
104 |
| - int[] y = new int[n]; |
105 |
| - |
106 |
| - for (int a : x) { |
107 |
| - x[a] = sc.nextInt(); |
108 |
| - } |
109 |
| - |
110 |
| - for (int b : y) { |
111 |
| - y[b] = sc.nextInt(); |
112 |
| - } |
113 |
| - } |
114 |
| - |
115 |
| - public static int solve() { |
116 |
| - |
117 |
| - } |
118 |
| -} |
| 1 | +// |
| 2 | +///* |
| 3 | +//Problem -> Solve History Ranking |
| 4 | +// |
| 5 | +//DUMB JERRY |
| 6 | +//DUMB JERRY |
| 7 | +// |
| 8 | +//Problem Statement |
| 9 | +// |
| 10 | +//As usual, Jerry and Tom are fighting. Tom wants to prove that Jerry is Dumb, So he made a problem and asked jerry. |
| 11 | +// |
| 12 | +//Given a sequence A of size N, and an operation. |
| 13 | +// |
| 14 | +//In one operation you can pick an element either from the front or back of the Sequence and write it down and delete it from the array. |
| 15 | +//Jerry has to perform the given operation until sequence A becomes empty. |
| 16 | +// |
| 17 | +//Tom wants the written sequence to be lexicographically maximum possible by performing the given operation on sequence A. |
| 18 | +// |
| 19 | +//Jerry can’t solve the problem on his own. So you have to help him. |
| 20 | +// |
| 21 | +//Note:- |
| 22 | +// |
| 23 | +//Sequence X of length N is lexicographically greater than Sequence Y of length N, if there exist such i (1<=i<=N), that Xi >Yi and for any j (1<=j<i) Xi=Yi. |
| 24 | +// |
| 25 | +//Constraint |
| 26 | +// |
| 27 | +//• 1 <= N <= 105 |
| 28 | +//• 0 <= Ai <= 109 |
| 29 | +// |
| 30 | +//• All input values are integer. |
| 31 | +// |
| 32 | +//Input Format |
| 33 | +// |
| 34 | +//• First-line contains N, length of the sequence A |
| 35 | +// |
| 36 | +//• Second line contains N space-separated integers denoting the sequence A. |
| 37 | +// |
| 38 | +//Output Format |
| 39 | +// |
| 40 | +//• In first print the lexicographically maximum sequence made by performing operations on sequence A |
| 41 | +// |
| 42 | +//Sample Input 1 |
| 43 | +// |
| 44 | +//3 |
| 45 | +// |
| 46 | +//3 1 2 |
| 47 | +// |
| 48 | +//Sample Output 1 |
| 49 | +// |
| 50 | +//3 2 1 |
| 51 | +// |
| 52 | +//Explanation of Sample 1 |
| 53 | +// |
| 54 | +//For test case1 |
| 55 | +// |
| 56 | +//We get sequence {3,1,2} if we |
| 57 | +//Pick the element from the front of the sequence (3) and delete it from the original sequence {1,2} |
| 58 | +//Pick the element from the front of the sequence (3,1) and delete it from the original sequence {2} |
| 59 | +//Pick the element from the front of the sequence (3,1,2) and delete it from the original sequence {} |
| 60 | +//We get sequence {3,2,1} if we |
| 61 | +//Pick the element from the front of the sequence (3) and delete it from the original sequence {1,2} |
| 62 | +//Pick the element from the back of the sequence (3,2) and delete it from the original sequence {1} |
| 63 | +//Pick the element from the front of the sequence (3,2,1) and delete it from the original sequence {} |
| 64 | +//We get sequence {2,3,1} if we |
| 65 | +//Pick the element from the back of the sequence (2) and delete it from the original sequence {3,1} |
| 66 | +//Pick the element from the front of the sequence (2,3) and delete it from the original sequence {1} |
| 67 | +//Pick the element from the front of the sequence (2,3,1) and delete it from the original sequence {} |
| 68 | +//We get sequence {2,1,3} if we |
| 69 | +//Pick the element from the back of the sequence (2) and delete it from the original sequence {3,1} |
| 70 | +//Pick the element from the back of the sequence (2,1) and delete it from the original sequence {3} |
| 71 | +//Pick the element from the front of the sequence (2,1,3) and delete it from the original sequence {} |
| 72 | +//Compare to other {3,2,1} is lexicographically largest. |
| 73 | +// |
| 74 | +//Things to Note for the Candidate |
| 75 | +// |
| 76 | +//You can use your own IDE like Visual Studio Code, Eclipse, or any other IDE that you are comfortable with to build your solution code. |
| 77 | +//The IDE provided on the platform is purely for submission. Avoid using the IDE for coding out the solution. |
| 78 | +//Test against any custom input in your own IDE. In the IDE provided on the platform, you cannot pass custom test cases and see the output. |
| 79 | +//Use standard input and standard output in your program for the IDE to run the test cases smoothly against your code. We are giving a sample problem statement along with a solution that will pass the test cases in the IDE. - Sample Problem Statement (Right Click and Open in New Tab to view.) |
| 80 | +// |
| 81 | +// |
| 82 | +// |
| 83 | +// */ |
| 84 | +// |
| 85 | +// |
| 86 | +///* package whatever; // don't place package name! */ |
| 87 | +// |
| 88 | +//import java.util.*; |
| 89 | +//import java.lang.*; |
| 90 | +//import java.io.*; |
| 91 | +// |
| 92 | +///* Name of the class has to be "Main" only if the class is public. */ |
| 93 | +//class Relevel_Test |
| 94 | +//{ |
| 95 | +// |
| 96 | +// public static void main (String[] args) throws java.lang.Exception |
| 97 | +// { |
| 98 | +// // your code goes here |
| 99 | +// Scanner sc = new Scanner(System.in); |
| 100 | +// int m = sc.nextInt(); |
| 101 | +// int n = sc.nextInt(); |
| 102 | +// |
| 103 | +// int[] x = new int[m]; |
| 104 | +// int[] y = new int[n]; |
| 105 | +// |
| 106 | +// for (int a : x) { |
| 107 | +// x[a] = sc.nextInt(); |
| 108 | +// } |
| 109 | +// |
| 110 | +// for (int b : y) { |
| 111 | +// y[b] = sc.nextInt(); |
| 112 | +// } |
| 113 | +// } |
| 114 | +// |
| 115 | +// public static int solve() { |
| 116 | +// |
| 117 | +// } |
| 118 | +//} |
0 commit comments