exec_outcome
stringclasses
1 value
code_uid
stringlengths
32
32
file_name
stringclasses
111 values
prob_desc_created_at
stringlengths
10
10
prob_desc_description
stringlengths
63
3.8k
prob_desc_memory_limit
stringclasses
18 values
source_code
stringlengths
117
65.5k
lang_cluster
stringclasses
1 value
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_time_limit
stringclasses
27 values
prob_desc_sample_outputs
stringlengths
2
796
prob_desc_notes
stringlengths
4
3k
lang
stringclasses
5 values
prob_desc_input_from
stringclasses
3 values
tags
listlengths
0
11
src_uid
stringlengths
32
32
prob_desc_input_spec
stringlengths
28
2.37k
difficulty
int64
-1
3.5k
prob_desc_output_spec
stringlengths
17
1.47k
prob_desc_output_to
stringclasses
3 values
hidden_unit_tests
stringclasses
1 value
PASSED
505ce6b4a375255b73754f9cb43f102f
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /* @author kalZor */ public class Tas...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
0b55e003df17142a53f914b05c8c90e4
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class B { // 5 7 4 3 2 6 1 static boolean tests = false; static void solve(){ int left = 1, right = in.nextInt(); int kept = -1; while (true){ if (left == right){ out.println("! "+left); ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
7e904f91297c1e08f2e2db746aad8a8f
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
// Working program with FastReader import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; // import jdk.internal.org.jline.terminal.impl.PosixSysTerminal; import java.util.*; import java.io.*; public clas...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
10672322f1810dadf07dbd55a1aa6223
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; /** * # * * @author pttrung */ public class C_Rou...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
5bb8525736049b2eec0c4677f538c797
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.InputMismatchException; /** * Created by Wilson on * Feb. 08, 2021 */ public class InteractiveProgram { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = n...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
6b3eff9e8af436e08052dfe8d306c66c
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Solver { public static void main(String[] args) { FastReader in = new FastReader(); int t = 1; while (t-- > 0) { solve(in); } } public static void solve(FastReader in) { ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
df154ed582f941299b76767607c1c64a
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class Question3 { static Scanner sc= new Scanner(System.in); static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); // static Reader sc = new Reader(); public static void main(String[] args) throws IOException { solve(); bw.c...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
c77a729e919e0b74b3c2bf9cf35c1043
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class _1486_C1 { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); int lbound = 1; int rbound = n; int res = 0; while(lbound <...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
addbfe57e49592d25203eff6b8dc881e
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import com.sun.jdi.IntegerType; import com.sun.jdi.IntegerValue; import com.sun.jdi.connect.Connector; import javax.lang.model.type.IntersectionType; import javax.security.auth.login.AccountNotFoundException; import javax.swing.*; import java.sql.Array; import java.util.*; import java.lang.*; import java.io....
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
fd4b519833fa6022a9d2dfb79b1794f6
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
/** * @author Nitin Bhakar * */ import java.io.*; import java.util.*; public class Codeforces{ static long mod = 1000000007L; static int ninf = Integer.MIN_VALUE; static int inf = Integer.MAX_VALUE; static void swap(int[] a,int i,int j) {int temp = a[i]; a[i] = a[j]; a[j] = t...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
679f8978f063a2086ec0f7bcbf660426
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.math.BigInteger; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Ar...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
7bc230573231f1799971cfc59fb07545
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class Guessing_the_greatest { static StringBuilder sb; static dsu dsu; static long fact[]; static long mod = (int) (1e9); static void solve() { int n = i(); int lo = 1; int hi = n+1; while(lo+1 < hi){ int mid = lo + (hi-lo)/2; ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
fbeef33793871812d3d4eb50ec31ac8d
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(String s) { try { br = new BufferedReader(new FileReader(s)); } catch (FileNotFoundEx...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
b3569ba4ce8fa9371f767a547c7b663a
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class Main { static long mod = (long) 1e9 + 7; static long mod1 = 998244353; public static void main(String[] args) { InputStream inputStream = Sy...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
56d282c2c34e58d44b6af32ab25907f2
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; public class Codeforces { static Scanner sc; public static void main(String[] args){ sc = new Scanner(System.in); int n = sc.nextInt(); int l = 1, r = n; int temp = get2ndMax(l, r); if(get2ndMax(l, temp) == temp){ l = 1; ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
03a1f700dc462f5978560b7c4e46f9df
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.Optional; import java.util.Scanner; public class ProblemC { final Scanner scanner; public static void main(String[] args) { new ProblemC().solve(); } ProblemC() { scanner = new Scanner(System.in); } void solve() { int n = scanner.nextIn...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
28590d075ecd2ed0d94f5bdd3d16df26
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { static Scanner sc=new Scanner(System.in); static int ask(int l,int r) { if(l==r) r...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 11
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
28c080175e0fc58d62d289cef9d25448
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.util.concurrent.LinkedBlockingDeque; import javax.sql.rowset.spi.SyncResolver; import java.io.*; import java.nio.channels.NonReadableChannelException; import java.text.DateFormatSymbols; import static java.lang.System.out; public class CpTemp{ static long a[]; st...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
c082a59d8269a1b08c908bad3b79e0d3
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class C { static FastScanner sc = new FastScanner(); public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); out.println("! " + solve(n)); out.close(); } ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
5321f651e582f83ee7d0fc16b9111a72
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class C { static FastScanner sc = new FastScanner(); public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); out.println("! " + solve(n)); out.close(); } ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
189622baecb671413ffb4374780993fe
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class C { static FastScanner sc = new FastScanner(); public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); out.println("! " + solve(n)); out.close(); } ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
220cd95493f24a2a459f18a1ca05c46f
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class C { static FastScanner sc = new FastScanner(); public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); out.println("! " + solve(n)); out.close(); } ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
3d9573ba85f8dfc82f6eab7aa95ad2c4
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class C { static FastScanner sc = new FastScanner(); public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); out.println("! " + solve(n)); out.close(); } ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
137f15ee12457e1a09248295cc73e4ae
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.math.BigInteger; //import javafx.util.*; public final class B { static StringBuilder ans=new StringBuilder(); static FastReader in=new FastReader(); static ArrayList<ArrayList<Integer>> g; static long mod=1000000007; static int ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
cc7709722ca9e29d071fdcbec8bd3384
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.math.BigInteger; //import javafx.util.*; public final class B { static StringBuilder ans=new StringBuilder(); static FastReader in=new FastReader(); static ArrayList<ArrayList<Integer>> g; static long mod=1000000007; static int ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
d7266bedb4160c29750536bf04c50a7d
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class Prb2 { static PrintWriter pw; static Scanner sc; static long mod = 1000000000+7; static void print(final String arg) { pw.write(arg); pw.flush(); } st...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
98f4c16a56f051873cd745b1837280e9
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; // import java.util.concurrent.CountDownLatch; // import javax.lang.model.element.QualifiedNameable; // import javax.swing.ViewportLayout; // import javax.swing.plaf.basic.BasicTreeUI.TreeCancelEditingAction; // import javax.swing.plaf.metal.MetalComboBoxUI.MetalPropertyChangeListener; // im...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
db67b69317cb3e0ed78fc2fc26f55bc4
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.PriorityQueue; import java.util.StringTokenizer; public class C { public static void main(String[] args){ ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
481740478a374bd2a0b53cdb5c38236a
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.PriorityQueue; import java.util.StringTokenizer; public class C { public static void main(String[] args){ ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
d2e8401f92468bb925f588a1e69ab1ee
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.PriorityQueue; import java.util.StringTokenizer; public class C { public static void main(String[] args){ ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
76d445053b02f16ac0440c38850b0ec1
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.PriorityQueue; import java.util.StringTokenizer; public class C { public static void main(String[] args){ ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
e876677f41943a39447700a0fc2791db
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class C_1_Guessing_the_Greatest_easy_version{ static Scanner sc = new Scanner(System.in); // @Harshit Maurya public static void reverse(int[] arr, int l, int r) { int d = (r - l + 1) / 2; for (int i = 0; i < d; i++) { int t = arr[l + i]; arr[l + i] = arr[r - i...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
be8bed18486a21a00fb540c004c5a8a4
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.StringTokenizer; import static java.lang.Double.parseDouble; import static java.lang.Integer.compare; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.System.in; public class Main { private static final int MOD =...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
0f51081858c985ac1c8bd1a8b925d769
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class cf1{ public static class FastReader { BufferedReader br; StringTokenizer st; public...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
616741c0b2fa549dbb503e547a5bf4db
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class cf1{ public static class FastReader { BufferedReader br; StringTokenizer st; public...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
6b0c5aeba6db9d66b1a6f75f472abdb8
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class cf1{ public static class FastReader { BufferedReader br; StringTokenizer st; public...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
1639efb32aa6bc62e4047f6ccfda6382
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class cf1{ public static class FastReader { BufferedReader br; StringTokenizer st; public...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
9073d6c95fcdd73deff69f0b357c550e
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class cf1{ public static class FastReader { BufferedReader br; StringTokenizer st; public...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
befc3f962731aeaf8dcd25171f8c69b5
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class Main { static Scanner sc; static PrintWriter pw; public static int query(int l, int r) throws IOException { pw.println("? " + l + " " + r); pw.flush(); return sc.nextInt(); } public static void main(String[] args) throws IOException { sc =...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
f7c66260e2138120653719b205335c53
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class Main { static Scanner sc; static PrintWriter pw; public static int query(int l, int r) throws IOException { pw.println("? " + l + " " + r); pw.flush(); return sc.nextInt(); } public static void main(String[] args) throws IOException { sc =...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
1c4a9ccef680ebb9214860a068280d83
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class Main { static Scanner sc; static PrintWriter pw; public static int query(int l, int r) throws IOException { pw.println("? " + l + " " + r); pw.flush(); return sc.nextInt(); } public static void main(String[] args) throws IOException { sc =...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
7ebf6f1a131b47d90d040388246eece6
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Practice { public static void main(String[] args) throws Exception { Scanner s = new Scanner(System.in); int n = s.nextInt(); System.out.flush(); getAns(n, s); } pr...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
05bf15e4fa17c100f78b210634611b8c
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { /* HashMap<> map=new HashMap<>(); TreeMap<> map=new TreeMap<>(); map.put(p,map.getOrDefault(p,0)+1); for(Map.Entry<> mx:map.entrySet()){ int v=mx.getValue(),k=mx.getKey(); } ArrayList<Pair<Char...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
56252476080ee72608a1c15e9a5f389b
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; import javafx.util.Pair; public class Main { public static void main(String[] args) { FastScanner input =new FastScanner(); int n = input...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
0ba9388cce931473f5e8d09d52a87cb3
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; import javafx.util.Pair; public class Main { public static void main(String[] args) { FastScanner input = new FastScanner(); int n = inpu...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
ab667e4e4fefb40c32e3aaaa8da2d309
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.File; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; public class Main { static Scanner in = new Scanner(System.in); // static Scanner in = new Scanner( new File("javain.txt")); public s...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
dc226d060e0217c6d52073c8ddbfa850
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.File; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; public class Main { static Scanner in = new Scanner(System.in); // static Scanner in = new Scanner( new File("javain.txt")); public s...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
0b0d4e22bec990825782353f35efda73
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class C { static int ans = Integer.MAX_VALUE; static String str = ""; static int[] dp; public static void main(String[] args) throws IOException { FastScanner fs=new FastScanner(); PrintWriter out = new PrintWriter(System....
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
da8de0750f708ddd464cba52c7a1ce40
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.math.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; //--------------->>>>IF YOU ARE HERE FOR QUICKSORT HACK THEN SORRY NO HACK FOR YOU<<<------------------- public class a{ static long[] count...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
672f8411a4982a1d1fc50d04430ef232
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.io.PrintStream; //import java.util.*; public class Solution { pu...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
e865e7cef2fbf7dd26030098b4eec7db
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
//WHEN IN DOUBT , USE BRUTE FORCE !!!!!!!!! import java.lang.String; import java.io.*; import java.util.*; import java.util.StringTokenizer; //class Main //AtCoder() //class Solution // Codechef public class Solution2 //Codeforces { static Scanner sc=new Scanner(System.in); public static void main...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
e607cd3f3aa0303a64a5ad9512d2651f
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; /** * * @Har_Har_Mahadev */ public class C { private static long INF = 2000000000000000000L, M = 1000000007, MM = 998244353; private static int N = 0; public static void process() throws IOException { int n = sc.nextInt(); int sma...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
2c1e73f2840518f375fbcadfb3f3b613
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
/******************************************************************************* * author : dante1 * created : 18/02/2021 23:12 *******************************************************************************/ import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; impo...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
19050d3e17280145a1cfc73a684650a1
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Random; import java.util.StringTokenizer; public class TaskC { static long mod = (long) (1000000000+7); public static void main(String[] args) { // TODO Auto-generated...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
b4e155002977230d7f26ca5fbb56d02c
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Random; import java.util.StringTokenizer; public class TaskC { static long mod = (long) (1000000000+7); public static void main(String[] args) { // TODO Auto-generated...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
f21b5bf97755fc753957af4d93061736
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.lang.reflect.Array; import java.text.DecimalFormat; import java.util.*; import java.io.*; public class Equal { static class pair implements Comparable<pair> { int x; int y; public pair(int u, int v) { this.x = u; this.y = v; } ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
c299b02dcb70835618e3e1279f054d6b
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class C2 { public static boolean check(int l, int r, int v, BufferedReader in) throws IOException { System.out.printf("? %d %d\n", l, r); System.out.flush(); int ans = Integer.par...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
df52029960f0eb031ad3a4bef3c9a3fc
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class C { public static boolean check(int l, int r, int v, BufferedReader in) throws IOException { System.out.printf("? %d %d\n", l, r); System.out.flush(); int ans = Integer.pars...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
fef597ecea2dc0a9f3cee712d183141c
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
// 18-Feb-2021 import java.util.*; import java.io.*; public class C { static class FastReader { BufferedReader br; StringTokenizer st; private FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
634b84e2653c9b41807c742d4fe803f7
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class GuessingTheGreatestHard { MyScanner scanner = new MyScanner(); private int solve(int n) { int start = 0, end = n - 1; int secMax = ask(start, end); ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
af116e53e5068bb67177e3d3deb779d2
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class GuessingTheGreatest { MyScanner scanner = new MyScanner(); private int solve(int n) { int start = 0, end = n - 1; int secMax = ask(start, end); /...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
2b1da4d40ce2837d3b97076e03534da2
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; /** * @author Mubtasim Shahriar */ public class Cr703A { public static void main(String[] args) { InputStream inputStream = S...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
da37fa6de7b24d892b5bc684b3230e6c
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class D{ static FastScanner fs = null; public static void main(String[] args) { fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t = 1; while (t-->0) { int n = fs.nextInt(); System.out.println("? 1 "+n); System.out.flus...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
15413e20a3e58521714dc2a25251a7b7
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.PrintWriter; public class T1698C2 { private static final T1698C2FastScanner in = new T1698C2FastScanner(); private static final PrintWriter out = new PrintWriter(System.out); public static void main(St...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
87db2acf0bfeeeb23aea249e66ad3e34
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.Scanner; public class T1486C { static Scanner in = new Scanner(System.in); public static void main(String[] args) { int n = in.nextInt(); int left = 0; int right = n - 1; int secondMaximum = query(left, right); int positionMaximum = search(left, right...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
9fc705b026d8212c9a3142ba1ce586f8
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.Scanner; public class T1486C { static Scanner in = new Scanner(System.in); public static void main(String[] args) { int n = in.nextInt(); int left = 0; int right = n - 1; int secondMaximum = query(left, right); int positionMaximum = search(left, right...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
7596be8d7832a2b52e1b80fd896f3b3f
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Stack; ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
68b144bbae0d8e28df0f91a1a30e31c6
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Stack; ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
1391bf373a8ebf9ef2291835cbfca0f8
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.lang.reflect.Type; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.*; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.Future; import java.util.concurrent.FutureTas...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
161772fd6c96718d4e44ea7389a554ea
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
//package R703; import java.io.*; import java.math.*; import java.util.*; public class Q3 { static int INF = (int)(1e9); static long mod = (long)(1e9)+7; static long mod2 = 998244353; static long[] segtree; static char[] curans; static long ans; static String S; static ArrayList<Integer>[] graph; ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
80bba7ce8929777af3c057591d1b8e2b
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.List; import java.util.*; public class realfast implements Runnable { private static final int INF = (int) 1e9; // long in= 1000000007; long fac[]= new long[1000001]; ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
2bfeebe1509f2caec0c25c93e5ed5500
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.awt.*; import java.util.Scanner; public class Main { Scanner scan = new Scanner(System.in); public static void main(String[] args) { Main m = new Main(); // int q = scan.nextInt(); while (q-- > 0) m.solve(); } void solve() { int n = scan.nextInt(); ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
6513500c5d11a6b16e302307f976c52f
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.Scanner; public class GuessGreatest { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int l = 1; int r = n; int ans = 0; while (l < r) { if (r - l == 1) { System.out.println("? " + l + " " + r); System.out...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
7c3b2dac6707969a22fbf5447dfdb145
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.Scanner; public class Main { public static Scanner scammer = new Scanner(System.in); public static int querry(int left, int right, boolean rite){ if(left == right) return rite ? right + 1 : left - 1; System.out.print("? "); System.out.print(lef...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
18da4f0b1b151119f373b1f8e448e3d3
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class guessingthegreatesteasy { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(f.readLine()); int n = Integer.parseInt(st.nextToken());...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
6ad606f135c562af5e739838d464f809
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
//package codeforce.div2.r703; import java.util.HashMap; import java.util.Map; import java.util.Scanner; /** * @author pribic (Priyank Doshi) * @since 18/02/21 */ public class C { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { int T = 1;//sc.nextInt(...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
97e2e19c6f27019ced2ff15e75a0ec58
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
//package codeforce.div2.r703; import java.util.HashMap; import java.util.Map; import java.util.Scanner; /** * @author pribic (Priyank Doshi) * @since 18/02/21 */ public class C { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { int T = 1;//sc.nextInt(...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
ce29622244b81add15ede8cefa9aab62
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class Main { static FastScanner sc = new FastScanner(System.in); static PrintWriter pw = new PrintWriter(System.out); static StringBuilder sb = new StringBuilder(); public static void main(String[] args) throws Exception { int n = sc.nextIn...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
840460089ecf99e5beac21430f2a947c
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class MainC { static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
7f3e6d93a49d372c7bb8f688dc66d2f3
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = 1; while (t-- > 0) { int n = sc.nextInt(); int l = 1; int r = n; int x = -1; ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
490877d18b416193996376d3f4a0a516
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String[] args) { FastScanner in = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int low = 1, high = n; out.println("? "+low+" "+high); out.flush()...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
fe467e62a3b406278d24af0e292fdd5b
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class guessing { //--------------------------INPUT READER--------------------------------// static class fs { public BufferedReader br; StringTokenizer st = new StringTokenizer(""); public fs() { this(System.in); } public f...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
d7bdf2b120e186a49ce275ba0d493f98
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; // import java.lang.*; // import java.math.*; public class Codeforces { static FastReader sc=new FastReader(); static PrintWriter out=new PrintWriter(System.out); static long mod=1000000007; // static long mod=998244353; static int MAX=Integer.MAX_VALUE; static...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
07820147e1e4038aa24867e3223d0868
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class CodeForces { static BufferedReader br; public static void main(String[] args) throws Exception { br=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); int l=1,r=n; while(l<r) { int ind=query(l,r)...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
ef3103e0c4ce9c730d54e320fac11c91
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class CodeForces { static BufferedReader br; public static void main(String[] args) throws Exception { br=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); int l=1,r=n; while(l<r) { int ind=query(l,r)...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
c4fc00f592076f623d091b9c49ee1f09
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int left = 1; int right = n; while(right - left + 1 > 2) { System.out.pri...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
fec521848829b5eec1a8c9543f26053b
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.*; public class Main { static class point { long val, time, t3; point(long val, long time, int t3) { this.val = val; this.time = time; ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
66e0e49e2129c36d4a4041b39c735f8e
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class Guessing_The_Greatest { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
93bac2d924e68a723d057eef4b4f00f3
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; import java.awt.*; public class C { BufferedReader in; PrintWriter ob; StringTokenizer st; public static void main(String[] args) throws IOException { new C().run(); } void run() throws IOException { in=new BufferedReader(new ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
e360ccc296c1f6d16abbfde05e2fb3bd
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; import java.awt.*; public class C { BufferedReader in; PrintWriter ob; StringTokenizer st; public static void main(String[] args) throws IOException { new C().run(); } void run() throws IOException { in=new BufferedReader(new InputStreamRe...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
af076ed9303a75a7e29b5186eaec3a7d
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.Scanner; public class C { static Scanner sc = new Scanner(System.in); public static long ask(long l, long r) { if(l >= r) return -1; System.out.println("? " + l + " " + r); long x = sc.nextLong(); return x; } public static void main(String[] args) { long n = sc...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
5f67a419f74b148f88801dea22f46b37
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C { public static void main(String[] args) { FastScanner fs = new FastScanner(); int t = 1;//fs.nextInt(); while (t-- > 0) { int ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
2a6293c7e926e67f4adc6deff9a9e4f8
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
// Main Code at the Bottom import java.util.*; import java.io.*; public class Main{ //Fast IO class static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { boolean env=System.getProperty("ONLINE_JUDGE") != null; //env=...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
b86bec9bcb2b309cdf191819e22870f9
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class GuessingTheGreatest implements Closeable { private InputReader in = new InputReade...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
bfcfd360d6ae0364f1d1c0c1c1abf6a1
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class C { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
10de2140c70b33e8f22c144bab520c79
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class C { private static int count; private static void flush(){System.out.flush();} private static void ask(int l, int r) throws Exception { count++; if(count>40) throw new Exception(); System.out.println("? ...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
d24231f56378789b792d114026a09957
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io....
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
e66d64880205fedf17c4833eafa97b36
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.util.*; import java.io.*; public class EdA { static long[] mods = {1000000007, 998244353, 1000000009}; static long mod = mods[0]; public static MyScanner sc; public static PrintWriter out; public static void main(String[] omkar) throws Exception{ // TODO Auto-generated method stub sc =...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
273d96f94f76317c35ffef67b9acc9c4
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static int ask(int l,int r) throws IOException { if(l==r)return -1; pw.println("? "+l+" "+r); pw.flush(); return sc.nextInt(); } static void main() throws Exception{ int n=sc.nextInt(); int scnd=ask(1, n); int lo=1,hi=n; while((h...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output
PASSED
0a726a4df6728001b289c0bcc70e1beb
train_109.jsonl
1613658900
The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme...
256 megabytes
//package Div2.C; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class GuessingTheGreatest { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.pa...
Java
["5\n\n3\n\n4"]
1 second
["? 1 5\n\n? 4 5\n\n! 1"]
NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $...
Java 8
standard input
[ "binary search", "interactive" ]
b3e8fe76706ba17cb285c75459508334
The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array.
1,600
null
standard output