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
sequencelengths
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
fab7fd23951252ccc3f41471114e632c
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
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 Codechef { public static void main (String[] args) throws IOException { BufferedReader f=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out=new PrintWriter(System.out); int t=Integer.parseInt(f.readLine()); while(t-->0){ StringTokenizer st=new StringTokenizer(f.readLine()); int a=Integer.parseInt(st.nextToken()); int b=Integer.parseInt(st.nextToken()); int c=Integer.parseInt(st.nextToken()); int val=Math.abs(b-c)+c-1; if(val<a-1){ out.println(2); } else if(val>a-1){ out.println(1); } else{ out.println(3); } } out.close(); f.close(); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
aca4b1ee79f63eb35b2f3d428eb26af3
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class a { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int ci = 0; ci < t; ci++) { long a = in.nextLong(); long b = in.nextLong(); long c = in.nextLong(); long ax = Math.abs(a - 1); long bx = Math.abs(b - c) + Math.abs(c - 1); System.out.println(ax < bx ? 1 : (ax > bx ? 2 : 3)); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
610225ca3f077d35f01e17d469c53efb
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class SolutionA{ static int twoElevators(int a,int b,int c){ int counta=a-1; int countb=Math.abs(b-c)+(c-1); //java.lang.Math if(counta<countb) return 1; if(counta>countb) return 2; return 3; } public static void main(String args[]){ Scanner input=new Scanner(System.in); int n=Integer.parseInt(input.nextLine()); for(int i=0;i<n;i++){ System.out.println(twoElevators(input.nextInt(),input.nextInt(),input.nextInt())); input.nextLine(); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
345accdde12e0969022bc6c3cc2c6753
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class ProbB { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long t = sc.nextLong(); while(t-->0) { long a = sc.nextLong(); long b = sc.nextLong(); long c = sc.nextLong(); //long x = a-1; long y = Math.abs(c-b)+c; if(a==y) { System.out.println(3); } else if(a<y) { System.out.println(1); } else { System.out.println(2); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
2742998fb497fd744b59e90e371fda75
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
// package codeforce; import java.util.*; import java.net.*; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.io.*; public class A { static class Node { int id1; int id2; Node(int v1, int w1){ this.id1= v1; this.id2=w1; } Node(){} } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while (st == null || !st.hasMoreElements()){ try { st = new StringTokenizer(br.readLine()); } catch (IOException e){ e.printStackTrace(); } } return st.nextToken(); } int nextInt(){ return Integer.parseInt(next()); } long nextLong(){ return Long.parseLong(next()); } double nextDouble(){ return Double.parseDouble(next()); } String nextLine(){ String str = ""; try{ str = br.readLine(); } catch (IOException e){ e.printStackTrace(); } return str; } int[] readArray(int n) { int[] a=new int[n]; for (int i=0; i<n; i++) a[i]=nextInt(); return a; } } static boolean[] seiveofEratoSthenes(int n) { boolean[] isPrime= new boolean[n+1]; Arrays.fill(isPrime, true); isPrime[0]=false; isPrime[1]= false; for(int i=2;i*i<=n;i++) { for(int j=2*i; j<=n;j=j+i) { isPrime[j]= false; } } return isPrime; } static int in = 2; // Function check whether a number // is prime or not public static boolean isPrime(int n) { // Check if number is less than // equal to 1 if (n <= 1) return false; // Check if number is 2 else if (n == 2) return true; // Check if n is a multiple of 2 else if (n % 2 == 0) return false; // If not, then just check the odds for (int i = 3; i <= Math.sqrt(n); i += 2) { if (n % i == 0) return false; } return true; } static class SortingComparator implements Comparator<Node>{ @Override public int compare(Node p1, Node p2) { // int n = p1.id1-p2.id1; // if(n!=0)return n; return p1.id2-p2.id2; } } static int pp =1; static long[] dp = new long[500001]; public static void main(String[] args) throws UnknownHostException { FastReader sc = new FastReader(); PrintWriter out = new PrintWriter(System.out); int t = sc.nextInt(); while(t--!=0) { long a = sc.nextLong(); long b = sc.nextLong(); long c = sc.nextLong(); long a1 = Math.abs(a-1); long b1= Math.abs(b-c)+Math.abs(c-1); if(a1<b1)System.out.println(1); else if(b1<a1)System.out.println(2); else System.out.println(3); } out.close(); } static long nextPowerOf2(long N) { // if N is a power of two simply return it if ((N & (N - 1)) == 0) return N; return 0x4000000000000000L >> (Long.numberOfLeadingZeros(N) - 2); } public static int[] solve(int[] arr, int[] it) { HashMap<Integer, Integer> hm = new HashMap<>(); for(int i=0; i<arr.length; i++) { hm.put(arr[i], hm.getOrDefault(arr[i], 0)+1); } for(int i=0; i<arr.length; i++) { it[i]= hm.get(arr[i]); } return it; } public static void rec(int l, int e, int[] arr) { if(l>e || e>=arr.length || l<=0)return; int mid = (e-l+1)%2==0?(e+l-1)/2:(e+l)/2; if(arr[mid]==0 ) { arr[mid]=pp; pp++; // if(pp>1)return; } if(e-mid-1<=mid-l-1) {rec(l, mid-1, arr); rec(mid+1, e, arr); } else { rec(mid+1, e, arr); rec(l, mid-1, arr); } } static double fact(double n) { int i=1; double fact=1; while(i<=n) { fact=fact*i; i++; } return fact; } static double combination(int n,int r) { double com=fact(n)/(fact(n-r)*fact(r)); return com; } static boolean digit(long n) { long ans = n; while(n>0) { long rem = n%10; if(rem!=0 && ans%rem!=0)return false; n=n/10; } return true; } static int nCr(int n, int r) { return fact(n) / (fact(r) * fact(n - r)); } // Returns factorial of n static int fact(int n) { int res = 1; for (int i = 2; i <= n; i++) res = res * i; return res; } static void sort(int[] a) { ArrayList<Integer> l=new ArrayList<>(); for (int i:a) l.add(i); Collections.sort(l, Collections.reverseOrder()); for (int i=0; i<a.length; i++) a[i]=l.get(i); } static boolean isPalindrome(char[] arr, int i, int j) { while(i<j) { if(arr[i]!=arr[j])return false; i++; j--; } return true; } static int lcm(int a, int b) { return (a / gcd(a, b)) * b; } static int max =0; static void dfs(int i, boolean[] vis , ArrayList<ArrayList<Integer>> adj) { max = Math.max(max, i); vis[i]= true; for(int e: adj.get(i)) { if(vis[e]==false) { dfs(e, vis, adj); } } } static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } static double pow(int a, int b) { long res= 1; while(b>0) { if((b&1)!=0) { res= (res*a); } a= (a*a); b= b>>1; } return res; } static void permute(String s , String answer, HashSet<String> hs) { if (s.length() == 0) { hs.add(answer); return; } for(int i = 0 ;i < s.length(); i++) { char ch = s.charAt(i); String left_substr = s.substring(0, i); String right_substr = s.substring(i + 1); String rest = left_substr + right_substr; permute(rest, answer + ch, hs); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
2625a5feb68bb85dae631c0e29fe5742
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Arrays; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; public class quesA { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i=0;i<t;i++) { int a = sc.nextInt();//input.get(0); int b = sc.nextInt();//input.get(1); int c = sc.nextInt();//input.get(2); if (a==1) { System.out.println("1"); }else if (Math.abs(a-1)<(Math.abs(b-c)+Math.abs(c-1))) { System.out.println("1"); }else if (Math.abs(a-1)>(Math.abs(b-c)+Math.abs(c-1))) { System.out.println("2"); }else System.out.println("3"); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
f35bf3eb5dae97e937a9b65ee61ed03a
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class TwoElevators { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0 ) { int a = (sc.nextInt()); int b = (sc.nextInt()); int c = (sc.nextInt()); int ml = Math.abs(a - 1); int m = Math.abs(c - b ); m+=Math.abs(c-1); if (ml < m) System.out.println(1); else if (m < ml) System.out.println(2); else System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
975273517aedea29917e927b27e8e5f8
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
/***** ---> :) Vijender Srivastava (: <--- *****/ import java.util.*; import java.lang.*; import java.io.*; public class Main { static FastReader sc =new FastReader(); static PrintWriter out=new PrintWriter(System.out); static long mod=(long)32768; static StringBuilder sb = new StringBuilder(); /* start */ public static void main(String [] args) { int testcases = 1; testcases = i(); // calc(); while(testcases-->0) { solve(); } out.flush(); out.close(); } static void solve() { long a= l(),b = l(),c = l(); long x = a-1,y = Math.abs(c-b)+Math.abs(c-1); if(x==y)pl(3); else if(x>y)pl(2); else pl(1); } /* end */ static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } // print code start static void p(Object o) { out.print(o); } static void pl(Object o) { out.println(o); } static void pl() { out.println(""); } // print code end // static int i() { return sc.nextInt(); } static String s() { return sc.next(); } static long l() { return sc.nextLong(); } static char[] inputC() { String s = sc.nextLine(); return s.toCharArray(); } static int[] input(int n) { int A[]=new int[n]; for(int i=0;i<n;i++) { A[i]=sc.nextInt(); } return A; } static long[] inputL(int n) { long A[]=new long[n]; for(int i=0;i<n;i++) { A[i]=sc.nextLong(); } return A; } static long[] putL(long a[]) { long A[]=new long[a.length]; for(int i=0;i<a.length;i++) { A[i]=a[i]; } return A; } static String[] inputS(int n) { String A[]=new String[n]; for(int i=0;i<n;i++) { A[i]=sc.next(); } return A; } static int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } static long gcd(long a, long b) { if (a == 0) return b; return gcd(b % a, a); } static int lcm(int a, int b) { return (a / gcd(a, b)) * b; } static String reverse(String s) { StringBuffer p=new StringBuffer(s); p.reverse(); return p.toString(); } static int min(int a,int b) { return Math.min(a, b); } static int min(int a,int b,int c) { return Math.min(a, Math.min(b, c)); } static int min(int a,int b,int c,int d) { return Math.min(a, Math.min(b, Math.min(c, d))); } static int max(int a,int b) { return Math.max(a, b); } static int max(int a,int b,int c) { return Math.max(a, Math.max(b, c)); } static int max(int a,int b,int c,int d) { return Math.max(a, Math.max(b, Math.max(c, d))); } static long min(long a,long b) { return Math.min(a, b); } static long min(long a,long b,long c) { return Math.min(a, Math.min(b, c)); } static long min(long a,long b,long c,long d) { return Math.min(a, Math.min(b, Math.min(c, d))); } static long max(long a,long b) { return Math.max(a, b); } static long max(long a,long b,long c) { return Math.max(a, Math.max(b, c)); } static long max(long a,long b,long c,long d) { return Math.max(a, Math.max(b, Math.max(c, d))); } static long sum(int A[]) { long sum=0; for(int i : A) { sum+=i; } return sum; } static long sum(long A[]) { long sum=0; for(long i : A) { sum+=i; } return sum; } static long mod(long x) { return ((x%mod + mod)%mod); } static long power(long x, long y) { if(y==0) return 1; if(x==0) return 0; long res = 1; while (y > 0) { if (y % 2 == 1) res = (res * x) ; y = y >> 1; x = (x * x); } return res; } static boolean prime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; double sq=Math.sqrt(n); for (int i = 5; i <= sq; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } static boolean prime(long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; double sq=Math.sqrt(n); for (int i = 5; i <= sq; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } static long[] sort(long a[]) { ArrayList<Long> arr = new ArrayList<>(); for(long i : a) { arr.add(i); } Collections.sort(arr); for(int i = 0; i < arr.size(); i++) { a[i] = arr.get(i); } return a; } static int[] sort(int a[]) { ArrayList<Integer> arr = new ArrayList<>(); for(Integer i : a) { arr.add(i); } Collections.sort(arr); for(int i = 0; i < arr.size(); i++) { a[i] = arr.get(i); } return a; } //pair class private static class Pair implements Comparable<Pair> { long first, second; public Pair(long f, long s) { first = f; second = s; } @Override public int compareTo(Pair p) { if (first < p.first) return 1; else if (first > p.first) return -1; else { if (second > p.second) return 1; else if (second < p.second) return -1; else return 0; } } } // segment t start static long seg[] ; static void build(long a[], int v, int tl, int tr) { if (tl == tr) { seg[v] = a[tl]; } else { int tm = (tl + tr) / 2; build(a, v*2, tl, tm); build(a, v*2+1, tm+1, tr); seg[v] = Math.min(seg[v*2] , seg[v*2+1]); } } static long query(int v, int tl, int tr, int l, int r) { if (l > r || tr < tl) return Integer.MAX_VALUE; if (l == tl && r == tr) { return seg[v]; } int tm = (tl + tr) / 2; return (query(v*2, tl, tm, l, min(r, tm))+ query(v*2+1, tm+1, tr, max(l, tm+1), r)); } static void update(int v, int tl, int tr, int pos, long new_val) { if (tl == tr) { seg[v] = new_val; } else { int tm = (tl + tr) / 2; if (pos <= tm) update(v*2, tl, tm, pos, new_val); else update(v*2+1, tm+1, tr, pos, new_val); seg[v] = Math.min(seg[v*2] , seg[v*2+1]); } } // segment t end // }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
d1db25e7093b08b2d25f7568a7a1f04f
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class A { public static void main(String[] args) { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t = fs.nextInt(); while (t-- > 0) { int n = fs.nextInt(); int k=fs.nextInt(); int m=fs.nextInt(); // int arr[]=fs.readArray(n); System.out.println(check(n,k,m)); } // out.close(); } static int check(int a,int b,int c){ int x=a-1; int y=Math.abs(c-b)+c-1; int z=Math.min(x,y); if(x==y) return 3; if(z==x) return 1; return 2; } /* HELPER FUNCTION's */ static final Random random = new Random(); static final int mod = 1_000_000_007; static void ruffleSort(int[] a) { int n = a.length;//shuffle, then sort for (int i = 0; i < n; i++) { int oi = random.nextInt(n), temp = a[oi]; a[oi] = a[i]; a[i] = temp; } Arrays.sort(a); } static long add(long a, long b) { return (a + b) % mod; } static long sub(long a, long b) { return ((a - b) % mod + mod) % mod; } static long mul(long a, long b) { return (a * b) % mod; } /* fast exponentiation */ static long exp(long base, long exp) { if (exp == 0) return 1; long half = exp(base, exp / 2); if (exp % 2 == 0) return mul(half, half); return mul(half, mul(half, base)); } /* end of fast exponentiation */ static long[] factorials = new long[2_000_001]; static long[] invFactorials = new long[2_000_001]; static void precompFacts() { factorials[0] = invFactorials[0] = 1; for (int i = 1; i < factorials.length; i++) factorials[i] = mul(factorials[i - 1], i); invFactorials[factorials.length - 1] = exp(factorials[factorials.length - 1], mod - 2); for (int i = invFactorials.length - 2; i >= 0; i--) invFactorials[i] = mul(invFactorials[i + 1], i + 1); } static long nCk(int n, int k) { return mul(factorials[n], mul(invFactorials[k], invFactorials[n - k])); } /* sort ascending and descending both */ static void sort(int[] a,int x) { ArrayList<Integer> l = new ArrayList<>(); for (int i : a) l.add(i); if(x==0) { Collections.sort(l); } if(x==1){ Collections.sort(l,Collections.reverseOrder()); } for (int i = 0; i < a.length; i++) a[i] = l.get(i); } /* sort String acc. to character */ static String sortString(String s){ char ch[]=s.toCharArray(); Arrays.sort(ch); String s1=String.valueOf(ch); return s1; } // lcm(a,b) * gcd(a,b) = a * b public static long _lcm(long a, long b) { return (a / _gcd(a, b)) * b; } // euclidean algorithm time O(max (loga ,logb)) public static long _gcd(long a, long b) { while (a > 0) { long x = a; a = b % a; b = x; } return b; } /* Pair Class implementation */ static class Pair<K, V> { K ff; V ss; public Pair(K ff, V ss) { this.ff = ff; this.ss = ss; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; Pair<?, ?> pair = (Pair<?, ?>) o; return ff.equals(pair.ff) && ss.equals(pair.ss); } @Override public int hashCode() { return Objects.hash(ff, ss); } @Override public String toString() { return ff.toString() + " " + ss.toString(); } } /* pair class ends here */ /* fast input output class */ static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } long[] readArrayL(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } long nextLong() { return Long.parseLong(next()); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
7e578a623b69323a100c62a742f5b02b
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class A { public static void main(String[] args) { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t = fs.nextInt(); while (t-- > 0) { int n = fs.nextInt(); int k=fs.nextInt(); int m=fs.nextInt(); // int arr[]=fs.readArray(n); System.out.println(check(n,k,m)); } // out.close(); } static int check(int a,int b,int c){ if(c<b){ if(a>b) return 2; else if(a==b) return 3; else return 1; } if(b>1) { if ((2 * Math.abs(b - c))+(b-1) > Math.abs(a - 1)) return 1; else if ((2 * Math.abs(b - c)) +(b-1)< Math.abs(a - 1)) return 2; else return 3; } if ((2 * Math.abs(b - c)) > Math.abs(a - 1)) return 1; else if ((2 * Math.abs(b - c))< Math.abs(a - 1)) return 2; else return 3; } /* HELPER FUNCTION's */ static final Random random = new Random(); static final int mod = 1_000_000_007; static void ruffleSort(int[] a) { int n = a.length;//shuffle, then sort for (int i = 0; i < n; i++) { int oi = random.nextInt(n), temp = a[oi]; a[oi] = a[i]; a[i] = temp; } Arrays.sort(a); } static long add(long a, long b) { return (a + b) % mod; } static long sub(long a, long b) { return ((a - b) % mod + mod) % mod; } static long mul(long a, long b) { return (a * b) % mod; } /* fast exponentiation */ static long exp(long base, long exp) { if (exp == 0) return 1; long half = exp(base, exp / 2); if (exp % 2 == 0) return mul(half, half); return mul(half, mul(half, base)); } /* end of fast exponentiation */ static long[] factorials = new long[2_000_001]; static long[] invFactorials = new long[2_000_001]; static void precompFacts() { factorials[0] = invFactorials[0] = 1; for (int i = 1; i < factorials.length; i++) factorials[i] = mul(factorials[i - 1], i); invFactorials[factorials.length - 1] = exp(factorials[factorials.length - 1], mod - 2); for (int i = invFactorials.length - 2; i >= 0; i--) invFactorials[i] = mul(invFactorials[i + 1], i + 1); } static long nCk(int n, int k) { return mul(factorials[n], mul(invFactorials[k], invFactorials[n - k])); } /* sort ascending and descending both */ static void sort(int[] a,int x) { ArrayList<Integer> l = new ArrayList<>(); for (int i : a) l.add(i); if(x==0) { Collections.sort(l); } if(x==1){ Collections.sort(l,Collections.reverseOrder()); } for (int i = 0; i < a.length; i++) a[i] = l.get(i); } /* sort String acc. to character */ static String sortString(String s){ char ch[]=s.toCharArray(); Arrays.sort(ch); String s1=String.valueOf(ch); return s1; } // lcm(a,b) * gcd(a,b) = a * b public static long _lcm(long a, long b) { return (a / _gcd(a, b)) * b; } // euclidean algorithm time O(max (loga ,logb)) public static long _gcd(long a, long b) { while (a > 0) { long x = a; a = b % a; b = x; } return b; } /* Pair Class implementation */ static class Pair<K, V> { K ff; V ss; public Pair(K ff, V ss) { this.ff = ff; this.ss = ss; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; Pair<?, ?> pair = (Pair<?, ?>) o; return ff.equals(pair.ff) && ss.equals(pair.ss); } @Override public int hashCode() { return Objects.hash(ff, ss); } @Override public String toString() { return ff.toString() + " " + ss.toString(); } } /* pair class ends here */ /* fast input output class */ static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } long[] readArrayL(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } long nextLong() { return Long.parseLong(next()); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
4c3a23a35d117df5a6ac2de0a5c3c063
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.*; import java.math.*; public class A { static StringBuilder sb; static dsu dsu; static long fact[]; static long mod=(long)(1e9+7); static ArrayList<Integer>prime; //static int x[]; static long A[],dp[]; static int n; static ArrayList<Integer>adj[]; static ArrayList<Long>ll; static boolean visited[]; static int max; static int min; static void solve() { int a=i(),b=i(),c=i(); int ta=a-1; int tb=0; if(c>=b) tb=(c-b)+(c-1); else tb=(b-c)+(c-1); if(ta<tb) { System.out.println(1); } else if(ta>tb) { System.out.println(2); } else System.out.println(3); } public static void main(String[] args) { sb=new StringBuilder(); int t=i(); while(t-->0) { solve(); } System.out.println(sb); } //*******************************************Seive OF Erassosthenes n log n******************************************************* //int prime[]=new int[100000]; // // Arrays.fill(prime,-1); // // for(int i=2;i*i<prime.length;i++) // { // if(prime[i]==-1) // for(int j=i*i;j<prime.length;j+=i) // { // prime[j]=1; // } // // // } // ArrayList<Integer>l=new ArrayList<>(); // for(int i=2;i<prime.length;i++) // { // if(prime[i]==-1) // { // l.add(i); // } // } // System.out.println(l.size()); //*******************************************Seive OF Erassosthenes O(n) ******************************************************* //int n=100; // // int lp[]=new int[n+1];// Array of minimum prime factor of n numbers // ArrayList<Integer>pr=new ArrayList<>();// list of prime numbers // // for(int i=2;i<n;i++) // { // if(lp[i]==0) // { // lp[i]=i; // pr.add(i); // } // for(int j=0;(j<pr.size()) && (pr.get(j)<=lp[i])&& (i*pr.get(j)<=n);j++) // { // lp[i*pr.get(j)]=pr.get(j); // // } // // } // // System.out.println(Arrays.toString(lp)); // System.out.println(pr); // // //*******************************************NCR%P*********************************************************************** static long ncr(int n, int r) { if(r>n) return (long)0; long res=fact[n]%mod; //System.out.println(res); res=((long)(res%mod)*(long)(p(fact[r],mod-2)%mod))%mod; res=((long)(res%mod)*(long)(p(fact[n-r],mod-2)%mod))%mod; //System.out.println(res); return res; } //*******************************************NCR%P*********************************************************************** static long p(long x, long y)//POWER FXN // { if(y==0) return 1; long res=1; while(y>0) { if(y%2==1) { res=(res*x)%mod; y--; } //if(y>0) { x=(x*x)%mod; //} y=y/2; } return res; } static long ceil(long num, long den) { return (long)(num+den-1)/den; } //*******************************************END******************************************************* static int LowerBound(long a[], long x, int i, int j) { //X is the key value int l=i;int r=j; int lb=-1; while(l<=r) { int m=(l+r)/2; if(a[m]>=x) { lb=m; r=m-1; } else l=m+1; } return lb; } static int UpperBound(long a[], long x, int i, int j) {// x is the key or target value int l=i,r=j; int ans=-1; while(l<=r) { int m=(l+r)/2; if(a[m]<=x) { ans=m; l=m+1; } else r=m-1; } return ans; } //*********************************Disjoint set union*************************// static class dsu { int parent[]; dsu(int n) { parent=new int[n+1]; for(int i=0;i<=n;i++) parent[i]=-1; } int find(int a) { if(parent[a]<0) return a; else { int x=find(parent[a]); parent[a]=x; return x; } } void merge(int a,int b) { a=find(a); b=find(b); if(a==b) return; parent[b]=a; } } //*******************************************PRIME FACTORIZE *****************************************************************************************************// static TreeMap<Integer,Integer> prime(long n) { TreeMap<Integer,Integer>h=new TreeMap<>(); long num=n; for(int i=2;i<=Math.sqrt(num);i++) { if(n%i==0) { int nt=0; while(n%i==0) { n=n/i; nt++; } h.put(i, nt); } } if(n!=1) h.put((int)n, 1); return h; } //*************CLASS PAIR *********************************************************************************************************************************************** static class pair implements Comparable<pair> { int x; int y; pair(int x, int y) { this.x = x; this.y = y; } public int compareTo(pair o) { return(int) (y-o.y); } public int hashCode() { final int temp = 14; int ans = 1; ans =x*31+y*13; return (int)ans; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null) { return false; } if (this.getClass() != o.getClass()) { return false; } pair other = (pair)o; if (this.x != other.x || this.y!=other.y) { return false; } return true; } } //*************CLASS PAIR ***************************************************************************************************************************************************** static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public int Int() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public String String() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public String next() { return String(); } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void print(Object... objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) writer.print(' '); writer.print(objects[i]); } } public void printLine(Object... objects) { print(objects); writer.println(); } public void close() { writer.close(); } public void flush() { writer.flush(); } } static InputReader in = new InputReader(System.in); static OutputWriter out = new OutputWriter(System.out); public static int[] sort(int[] a) { int n = a.length; ArrayList<Integer> l = new ArrayList<>(); for (int i : a) l.add(i); Collections.sort(l); for (int i = 0; i < l.size(); i++) a[i] = l.get(i); return a; } public static long[] sort(long[] a) { int n = a.length; ArrayList<Long> l = new ArrayList<>(); for (long i : a) l.add(i); Collections.sort(l); for (int i = 0; i < l.size(); i++) a[i] = l.get(i); return a; } public static long pow(long x, long y) { long res = 1; while (y > 0) { if (y % 2 != 0) { res = (res * x);// % modulus; y--; } x = (x * x);// % modulus; y = y / 2; } return res; } //GCD___+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public static long gcd(long x, long y) { if (x == 0) return y; else return gcd(y % x, x); } //****************LOWEST COMMON MULTIPLE ************************************************************************************************************************************* public static long lcm(long x, long y) { return (x * (y / gcd(x, y))); } //INPUT PATTERN****************************************************************************************************************************************************************** public static int i() { return in.Int(); } public static long l() { String s = in.String(); return Long.parseLong(s); } public static String s() { return in.String(); } public static int[] readArray(int n) { int A[] = new int[n]; for (int i = 0; i < n; i++) { A[i] = i(); } return A; } public static long[] readArray(long n) { long A[] = new long[(int) n]; for (int i = 0; i < n; i++) { A[i] = l(); } return A; } public int[][] deepCopy(int[][] matrix) { return java.util.Arrays.stream(matrix).map(el -> el.clone()).toArray($ -> matrix.clone()); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
a3ab6b2c5db2fc9321be29699c6425ac
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Ex3 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int x = in.nextInt(); for(int i = 0; i < x; i++) { int a = in.nextInt(); int b = in.nextInt(); int c = in.nextInt(); int b1 = Math.abs(b-c)+c; if(a > b1){ System.out.println(2); }else if(b1 > a){ System.out.println(1); }else { System.out.println(3); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
23dcf1d7bafbb03550b89dba9cb70496
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Football { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int a =sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int t1 = Math.abs(a-1); int t2 = Math.abs((b-c))+Math.abs((c-1)); if(t1 < t2) System.out.println("1"); else if(t1 > t2) System.out.println("2"); else System.out.println("3"); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
af4e16b5e7cebd07af9c92af03697894
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Two_Elevators { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if(a == 1 || (Math.abs(c - b) + (c - 1)) > a - 1) System.out.println(1); else if(Math.abs(c - b) + (c - 1) < a - 1) System.out.println(2); else System.out.println(3); } sc.close(); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
b48de39f677677a71ebdeac60e6c7b7b
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Main { public static void main(String args[]){ Scanner sc=new Scanner(System.in); int a=sc.nextInt(); while(a-->0) { int b=sc.nextInt(); int c=sc.nextInt(); int d=sc.nextInt(); int r=b-1; int e=Math.abs(d-c)+Math.abs(d-1); if(r==e) System.out.println("3"); else if(r<e) System.out.println("1"); else System.out.println("2"); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
f226347b6ebac905b0af69b5a94c9157
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class QuesA { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t=sc.nextInt(); while(t-- > 0){ int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); int s2; if(b<c) s2=2*c-b; else s2=b; if(a<s2) System.out.println(1); else if(a>s2) System.out.println(2); else System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
3e424c08cb9864cb1122eb31f4638654
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import javax.print.DocFlavor; import java.io.*; import java.math.BigInteger; import java.util.*; public class A { static FastScanner scan = new FastScanner(); static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int T = scan.nextInt(); for(int i =1;i<=T;i++){ solve(); } } public static void solve() { int a = scan.nextInt(); int b = scan.nextInt(); int c = scan.nextInt(); if(a==1){ System.out.println(1); return; } int x = Math.abs(b-c); int y = Math.abs(c-1); x =x +y; int z = Math.abs(a-1); if(x>z){ System.out.println(1); } else if(x<z){ System.out.println(2); } else{ System.out.println(3); } } static boolean isSorted(int[] arr){ for (int i =1;i<arr.length;i++) { if (arr[i - 1] > arr[i]) return false; } return true; } static long gcd(long A, long B) { if (B == 0) return A; return gcd(B, A % B); } static boolean isInteger(int n) { return Math.sqrt(n) % 1 == 0; } static class Vec { double x,y; public Vec(double x) { this.x=x; this.y=y; } } static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } String[] readStringArray(int n){ String[] arr = new String[n]; for (int i =0;i<n;i++)arr[i]=next(); return arr; } long nextLong() { return Long.parseLong(next()); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
a9cb0a1dd2b69fa6623e25c802579bc2
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t>0){ int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); if(a==1) System.out.println(1); else if(b<c && a< Math.abs(2*c-b)) System.out.println(1); else if(b>c && a<b) System.out.println(1); else if(b<c && a> Math.abs(2*c-b)) System.out.println(2); else if(b>c && a>b) System.out.println(2); else System.out.println(3); t--; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
6966a2a6197653f756cc958454056d1a
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); BufferedOutputStream os = new BufferedOutputStream(System.out); int n = Integer.parseInt(reader.readLine()); for (int i = 0; i < n; i++){ String[] lol = reader.readLine().split("\\s"); long first = Integer.parseInt(lol[0]) - 1; long second = (int) (Math.abs(Integer.parseInt(lol[2]) - Integer.parseInt(lol[1])) + Integer.parseInt(lol[2]) - 1); if (first < second) os.write("1\n".getBytes()); else if (first > second) os.write("2\n".getBytes()); else os.write("3\n".getBytes()); } os.flush(); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
ad0e208ae51f5de4684562d04065c727
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; import java.io.*; public class Competitive { static BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { int t = getInt(); while(t-- > 0){ String[] s = rd.readLine().split(" "); int a= toInt(s[0]), b = toInt(s[1]), c = toInt(s[2]); int c1 = a; int c2 = Math.abs(c-b) + c; System.out.println( (c1==c2)?3:((c1>c2)?2:1) ); } } static int getInt() throws IOException{ return toInt(rd.readLine()); } static int toInt(String n){ return Integer.parseInt(n); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
ab98a3df0e6c0885ceec90b354121be3
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static FastReader scan = new FastReader(); static PrintWriter sout = new PrintWriter(System.out); public static void main(String[] args) { int n = scan.nextInt(); while (n-->0) A(); sout.close(); } static void A(){ // System.out.println(Math.log(1000)/Math.log(1)); int n = scan.nextInt(); int m = scan.nextInt(); int l = scan.nextInt(); if (n == 1){ sout.println(1); }else{ if (m>=l){ if (n==m) sout.println(3); else if(n>m) sout.println(2); else sout.println(1); }else{ int r = Math.abs(l-m); if(r+m == n-r) { sout.println(3); }else if (r+m < n-r){ sout.println(2); }else sout.println(1); // sout.println(r); } } } static boolean isPalindrome(String str){ StringBuilder sb = new StringBuilder(str); return str.equals(sb.reverse().toString()); } static class Pair{ int x; int y; public Pair(int x , int y){ this.x = x; this.y = y; } @Override public String toString(){ return new String(x +" "+y); } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br=new BufferedReader(new InputStreamReader(System.in)); } String next() { while(st==null || !st.hasMoreElements()) { try { st=new StringTokenizer(br.readLine()); } catch(IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str=""; try { str=br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
82830dde2692db0ca56726b93519030c
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class cf1 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); System.out.println(solve(a,b,c)); } } public static int solve(int a,int b,int c){ if(a==1){ return 1; } if(c ==1 && Math.abs(a-1) > Math.abs(b-c)){ return 2; } int check1 = Math.abs(a-1); int check2 = Math.abs(b-c) + Math.abs(c-1); if(check1 < check2){ return 1; } else if(check2 < check1){ return 2; } else{ return 3; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
132e68f27e7ba4f8bb33323c1a55bd2d
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.StringTokenizer; public class Main { static long ans = 0; public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int T = Integer.parseInt(br.readLine()); while(T --> 0) { StringTokenizer st = new StringTokenizer(br.readLine(), " "); int temp = 0; ans = 0; int a = Integer.parseInt(st.nextToken()); int b = Integer.parseInt(st.nextToken()); int c = Integer.parseInt(st.nextToken()); a -= 1; temp = Math.abs(b-c); temp += c - 1; if(a > temp) { ans = 2; } else if(a < temp) { ans = 1; } else { ans = 3; } sb.append(ans).append('\n'); } System.out.println(sb); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
af75ecc495aac77fb6addd67b52a321e
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.util.ArrayList; import java.util.Collections; /* Name of the class has to be "Main" only if the class is public. */ public class A { public static void main (String[] args) throws Exception { // your code goes here FastScanner sc= new FastScanner(); int t = sc.nextInt(); while(t-->0){ int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if(a==1){ System.out.println(1); }else if(b==1){ int fs = a-1; int ss = 2*Math.abs(b-c); if(fs==ss){ System.out.println(3); }else if(fs<ss){ System.out.println(1); }else{ System.out.println(2); } }else{ int fs = a-1; int ss = Math.abs(b-c)+c-1; if(fs==ss){ System.out.println(3); }else if(fs<ss){ System.out.println(1); }else{ System.out.println(2); } } } } public static boolean isPrime(long n) { if(n < 2) return false; if(n == 2 || n == 3) return true; if(n%2 == 0 || n%3 == 0) return false; long sqrtN = (long)Math.sqrt(n)+1; for(long i = 6L; i <= sqrtN; i += 6) { if(n%(i-1) == 0 || n%(i+1) == 0) return false; } return true; } public static long gcd(long a, long b) { if(a > b) a = (a+b)-(b=a); if(a == 0L) return b; return gcd(b%a, a); } public static ArrayList<Integer> findDiv(int N) { //gens all divisors of N ArrayList<Integer> ls1 = new ArrayList<Integer>(); ArrayList<Integer> ls2 = new ArrayList<Integer>(); for(int i=1; i <= (int)(Math.sqrt(N)+0.00000001); i++) if(N%i == 0) { ls1.add(i); ls2.add(N/i); } Collections.reverse(ls2); for(int b: ls2) if(b != ls1.get(ls1.size()-1)) ls1.add(b); return ls1; } public static void sort(int[] arr) { //because Arrays.sort() uses quicksort which is dumb //Collections.sort() uses merge sort ArrayList<Integer> ls = new ArrayList<Integer>(); for(int x: arr) ls.add(x); Collections.sort(ls); for(int i=0; i < arr.length; i++) arr[i] = ls.get(i); } public static long power(long x, long y, long p) { //0^0 = 1 long res = 1L; x = x%p; while(y > 0) { if((y&1)==1) res = (res*x)%p; y >>= 1; x = (x*x)%p; } return res; } static class FastScanner { //I don't understand how this works lmao private int BS = 1 << 16; private char NC = (char) 0; private byte[] buf = new byte[BS]; private int bId = 0, size = 0; private char c = NC; private double cnt = 1; private BufferedInputStream in; public FastScanner() { in = new BufferedInputStream(System.in, BS); } public FastScanner(String s) { try { in = new BufferedInputStream(new FileInputStream(new File(s)), BS); } catch (Exception e) { in = new BufferedInputStream(System.in, BS); } } private char getChar() { while (bId == size) { try { size = in.read(buf); } catch (Exception e) { return NC; } if (size == -1) return NC; bId = 0; } return (char) buf[bId++]; } public int nextInt() { return (int) nextLong(); } public int[] nextInts(int N) { int[] res = new int[N]; for (int i = 0; i < N; i++) { res[i] = (int) nextLong(); } return res; } public long[] nextLongs(int N) { long[] res = new long[N]; for (int i = 0; i < N; i++) { res[i] = nextLong(); } return res; } public long nextLong() { cnt = 1; boolean neg = false; if (c == NC) c = getChar(); for (; (c < '0' || c > '9'); c = getChar()) { if (c == '-') neg = true; } long res = 0; for (; c >= '0' && c <= '9'; c = getChar()) { res = (res << 3) + (res << 1) + c - '0'; cnt *= 10; } return neg ? -res : res; } public double nextDouble() { double cur = nextLong(); return c != '.' ? cur : cur + nextLong() / cnt; } public double[] nextDoubles(int N) { double[] res = new double[N]; for (int i = 0; i < N; i++) { res[i] = nextDouble(); } return res; } public String next() { StringBuilder res = new StringBuilder(); while (c <= 32) c = getChar(); while (c > 32) { res.append(c); c = getChar(); } return res.toString(); } public String nextLine() { StringBuilder res = new StringBuilder(); while (c <= 32) c = getChar(); while (c != '\n') { res.append(c); c = getChar(); } return res.toString(); } public boolean hasNext() { if (c > 32) return true; while (true) { c = getChar(); if (c == NC) return false; else if (c > 32) return true; } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
0c884bb71b4828ae244df0513e962081
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; import java.util.*; //[row][column] public class cf_arhiv { public static void main(String[] args) { FastScanner scan = new FastScanner(); int n = scan.nextInt(); for (int i = 0; i < n; i++) { int a = scan.nextInt(); int b= scan.nextInt(); int c = scan.nextInt(); int first = Math.abs(a - 1); int second = Math.abs(b - c) + c - 1; if(first < second) System.out.println("1"); else if(first == second) System.out.println("3"); else System.out.println("2"); } } } class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(String s) { try { br = new BufferedReader(new FileReader(s)); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public FastScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String nextToken() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(nextToken()); } long nextLong() { return Long.parseLong(nextToken()); } double nextDouble() { return Double.parseDouble(nextToken()); }String nextLine() { String str = ""; try { if(st.hasMoreTokens()){ str = st.nextToken("\n"); } else{ str = br.readLine(); } } catch (IOException e) { e.printStackTrace(); } return str; } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
0a1844d5a1fc3cd48fd1201b0ce02d31
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class yuhi { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int first = a-1; int second = c>b ? (2*(c-b))+(b-1) : (b-c)+(c-1); if(first==second) { System.out.println(3); }else if(first>second) { System.out.println(2); }else System.out.println(1); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
0cca1d56c348f8d9df48d788818a4eb2
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } public static void main (String[] args) throws java.lang.Exception { try{ FastReader sc = new FastReader(); //your code goes here. int t = sc.nextInt(); while(t-->0){ int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); a = a-1; b = Math.abs(b-c); b += Math.abs(c-1); if(a<b) System.out.println(1); else if(a>b) System.out.println(2); else System.out.println(3); } } catch(Exception e){ return; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
50d41c2a4d3d46004348fc810051ee03
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class temp3 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i<t; i++) { int[] a = new int[3]; a[0] = sc.nextInt(); a[1] = sc.nextInt(); a[2] = sc.nextInt(); int a1 = Math.abs(a[0] - 1); int a2 = Math.abs(a[1] - a[2]) + Math.abs(a[2] - 1); if(a1<a2) System.out.println(1); else if(a1>a2) System.out.println(2); else System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
2740a2689f61842d313bb90294af4d3f
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; import java.util.*; public class cf { public static long gcd(long a, long b) { if (b == 0) { return a; } return gcd(b, a % b); } public static boolean isok(long x, long h, long k) { long sum = 0; if (h > k) { long t1 = h - k; long t = t1 * k; sum += (k * (k + 1)) / 2; sum += t - (t1 * (t1 + 1) / 2); } else { sum += (h * (h + 1)) / 2; } if (sum < x) { return true; } return false; } public static boolean binary_search(long[] a, long k) { long low = 0; long high = a.length - 1; long mid = 0; while (low <= high) { mid = low + (high - low) / 2; if (a[(int) mid] == k) { return true; } else if (a[(int) mid] < k) { low = mid + 1; } else { high = mid - 1; } } return false; } public static long lowerbound(long a[], long ddp) { long low = 0; long high = a.length; long mid = 0; while (low < high) { mid = low + (high - low) / 2; if (a[(int) mid] == ddp) { return mid; } if (a[(int) mid] < ddp) { low = mid + 1; } else { high = mid; } } // if(low + 1 < a.length && a[(int)low + 1] <= ddp){ // low++; // } if (low == a.length && low != 0) { low--; return low; } if (a[(int) low] > ddp && low != 0) { low--; } return low; } public static long upperbound(long a[], long ddp) { long low = 0; long high = a.length; long mid = 0; while (low < high) { mid = low + (high - low) / 2; if (a[(int) mid] <= ddp) { low = mid + 1; } else { high = mid; } } if (low == a.length) { return a.length - 1; } return low; } // public static class pair implements Comparable<pair> { // long w; // long h; // public pair(long w, long h) { // this.w = w; // this.h = h; // } // public int compareTo(pair b) { // if (this.w != b.w) // return (int) (this.w - b.w); // else // return (int) (this.h - b.h); // } // } public static class pair { long w; long h; public pair(long w, long h) { this.w = w; this.h = h; } } public static class trinary { long a; long b; long c; public trinary(long a, long b, long c) { this.a = a; this.b = b; this.c = c; } } public static long lowerboundforpairs(pair a[], long pr) { long low = 0; long high = a.length; long mid = 0; while (low < high) { mid = low + (high - low) / 2; if (a[(int) mid].w <= pr) { low = mid + 1; } else { high = mid; } } // if(low + 1 < a.length && a[(int)low + 1] <= ddp){ // low++; // } // if(low == a.length && low != 0){ // low--; // return low; // } // if(a[(int)low].w > pr && low != 0){ // low--; // } return low; } public static pair[] sortpair(pair[] a) { Arrays.sort(a, new Comparator<pair>() { public int compare(pair p1, pair p2) { return (int) p1.w - (int) p2.w; } }); return a; } public static boolean ispalindrome(String s) { long i = 0; long j = s.length() - 1; boolean is = false; while (i < j) { if (s.charAt((int) i) == s.charAt((int) j)) { is = true; i++; j--; } else { is = false; return is; } } return is; } public static void sort(long[] arr) { ArrayList<Long> a = new ArrayList<>(); for (long i : arr) { a.add(i); } Collections.sort(a); for (int i = 0; i < a.size(); i++) { arr[i] = a.get(i); } } public static void sortForObjecttypes(pair[] arr) { ArrayList<pair> a = new ArrayList<>(); for (pair i : arr) { a.add(i); } Collections.sort(a, new Comparator<pair>() { @Override public int compare(pair a, pair b) { return (int) (a.h - b.h); } }); for (int i = 0; i < a.size(); i++) { arr[i] = a.get(i); } } public static long power(long base, long pow, long mod) { long result = base; long temp = 1; while (pow > 1) { if (pow % 2 == 0) { result = ((result % mod) * (result % mod)) % mod; pow /= 2; } else { temp = temp * base; pow--; } } result = ((result % mod) * (temp % mod)); // System.out.println(result); return result; } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } float nextFloat() { return Float.parseFloat(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } void readArr(int[] ar, int n) { for (int i = 0; i < n; i++) { ar[i] = nextInt(); } } } public static int bSearchDiff(long[] a, int low, int high) { int mid = low + ((high - low) / 2); int hight = high; int lowt = low; while (lowt < hight) { mid = lowt + (hight - lowt) / 2; if (a[high] - a[mid] <= 5) { hight = mid; } else { lowt = mid + 1; } } return high - lowt + 1; } public static void solve(FastReader sc, PrintWriter w) throws Exception { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if (a == 1) { System.out.println(1); return; } if (a - 1 > Math.abs(c - b) + Math.abs(c - 1)) { System.out.println(2); } else if (a - 1 < Math.abs(c - b) + Math.abs(c - 1)) { System.out.println(1); } else { System.out.println(3); } } public static void main(String[] args) throws Exception { FastReader sc = new FastReader(); PrintWriter w = new PrintWriter(System.out); long o = sc.nextLong(); while (o > 0) { solve(sc, w); o--; } w.close(); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
235e0a48b25a8c863323dc73493dd0f2
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int testcase = input.nextInt(); for (int i = 0; i < testcase; i++) { int a = input.nextInt(); int b = input.nextInt(); int c = input.nextInt(); System.out.println(checkTime(a, b, c)); } input.close(); } public static int checkTime(int a, int b, int c) { int one = Math.abs(a - 1); int two = Math.abs(b - c) + Math.abs(c - 1); if (one == two) return 3; return one < two ? 1 : 2; } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
c7b19a4a58ff7f1072ed659fa3bef4d9
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) { new MainClass().execute(); } } class MainClass extends PrintWriter { MainClass() { super(System.out, true); } boolean cases = true; // Solution void solveIt(int testCaseNo) { long a = sc.nextLong(); long b = sc.nextLong(); long c = sc.nextLong(); if (a < abs(b - c) + c) { System.out.println(1); } else if (a > abs(b - c) + c) { System.out.println(2); } else { System.out.println(3); } } void solve() { int caseNo = 1; if (cases) for (int T = sc.nextInt(); T > 1; T--, caseNo++) { solveIt(caseNo); } solveIt(caseNo); } void execute() { long S = System.currentTimeMillis(); is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes()); out = new PrintWriter(System.out); this.sc = new FastIO(); solve(); out.flush(); long G = System.currentTimeMillis(); sc.tr(G - S + "ms"); } class FastIO { private boolean endOfFile() { if (bufferLength == -1) return true; int lptr = ptrbuf; while (lptr < bufferLength) { // _|_ if (!isThisTheSpaceCharacter(inputBufffferBigBoi[lptr++])) return false; } try { is.mark(1000); while (true) { int b = is.read(); if (b == -1) { is.reset(); return true; } else if (!isThisTheSpaceCharacter(b)) { is.reset(); return false; } } } catch (IOException e) { return true; } } private byte[] inputBufffferBigBoi = new byte[1024]; int bufferLength = 0, ptrbuf = 0; private int justReadTheByte() { if (bufferLength == -1) throw new InputMismatchException(); if (ptrbuf >= bufferLength) { ptrbuf = 0; try { bufferLength = is.read(inputBufffferBigBoi); } catch (IOException e) { throw new InputMismatchException(); } if (bufferLength <= 0) return -1; } return inputBufffferBigBoi[ptrbuf++]; } private boolean isThisTheSpaceCharacter(int c) { return !(c >= 33 && c <= 126); } private int skipItBishhhhhhh() { int b; while ((b = justReadTheByte()) != -1 && isThisTheSpaceCharacter(b)); return b; } private double nextDouble() { return Double.parseDouble(next()); } private char nextChar() { return (char) skipItBishhhhhhh(); } private String next() { int b = skipItBishhhhhhh(); StringBuilder sb = new StringBuilder(); while (!(isThisTheSpaceCharacter(b))) { sb.appendCodePoint(b); b = justReadTheByte(); } return sb.toString(); } private char[] readCharArray(int n) { char[] buf = new char[n]; int b = skipItBishhhhhhh(), p = 0; while (p < n && !(isThisTheSpaceCharacter(b))) { buf[p++] = (char) b; b = justReadTheByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private char[][] readCharMatrix(int n, int m) { char[][] map = new char[n][]; for (int i = 0; i < n; i++) map[i] = readCharArray(m); return map; } private int[] readIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } private long[] readLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } private int nextInt() { int num = 0, b; boolean minus = false; while ((b = justReadTheByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if (b == '-') { minus = true; b = justReadTheByte(); } while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else { return minus ? -num : num; } b = justReadTheByte(); } } private long nextLong() { long num = 0; int b; boolean minus = false; while ((b = justReadTheByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if (b == '-') { minus = true; b = justReadTheByte(); } while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else { return minus ? -num : num; } b = justReadTheByte(); } } private void tr(Object... o) { if (INPUT.length() != 0) System.out.println(Arrays.deepToString(o)); } } InputStream is; PrintWriter out; String INPUT = ""; final int ima = Integer.MAX_VALUE, imi = Integer.MIN_VALUE; final long lma = Long.MAX_VALUE, lmi = Long.MIN_VALUE; final long mod = (long) 1e9 + 7; FastIO sc; } // And I wish you could sing along, But this song is a joke, and the melody I // wrote, wrong
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
50e1908dfe607f0835a7d1d0d8a4f4fe
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while (t>0){ int a=scanner.nextInt(), b= scanner.nextInt() , c=scanner.nextInt(); int cnt_1 = a - 1; int cnt_2 = Math.abs(c-b) + c -1 ; if (cnt_1 < cnt_2) System.out.println(1); else if ( cnt_2 < cnt_1 ) System.out.println(2); else System.out.println(3); t--; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
2ba0913b7fa1b8e950e45914d4172746
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; import java.util.*; public class cf { static long[] p; public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); int t = Integer.parseInt(bf.readLine()); for(int testcases = 0; testcases < t; testcases++){ StringTokenizer stk = new StringTokenizer(bf.readLine()); int a = Integer.parseInt(stk.nextToken()); int b = Integer.parseInt(stk.nextToken()); int c = Integer.parseInt(stk.nextToken()); int first = Math.abs(a-1); int second = Math.abs(b-c) + Math.abs(c-1); if(first<second)pw.println(1); if(first==second)pw.println(3); if(first>second)pw.println(2); } pw.close(); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
58ce82a6b0496f5c2092b8b71c7628df
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); while(N-- > 0){ int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(); long t = (Math.abs(b - c)) + c; if(a == t) System.out.println(3); else if(a < t) System.out.println(1); else if(a > t) System.out.println(2); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
dc650fc7569848d2e6f451a362688d4e
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Two_Elevators { public static void main(String[] args) { Scanner Scan = new Scanner(System.in); //System.out.println("Test Cases :"); int t = Scan.nextInt(); int t1=0; while(t1<t) { t1++; //System.out.println("Enter a :"); long a = Scan.nextLong(); //System.out.println("Enter b :"); long b = Scan.nextLong(); //System.out.println("Enter c :"); long c = Scan.nextLong(); //STEP 1 long e=a-1; long d; if(c>b) d= (c-b)+(c-1); else d= b-1; //STEP 2 if(e<d) System.out.println("1"); else if(e>d) System.out.println("2"); else System.out.println("3"); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
6e1c3934ba2f33eaabf4afbfa1260705
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; import java.util.Arrays; public class Lift { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int numberOfSets = Integer.parseInt(br.readLine()); for (int nos = 0; nos < numberOfSets; nos++) { int[] data = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); if (data[2] > data[1]) { if ((data[0] - 1) < (2 * data[2] - data[1] - 1)) { System.out.println(1); } else { if ((data[0] - 1) > (2 * data[2] - data[1] - 1)) { System.out.println(2); } else { System.out.println(3); } } } else { if (data[0] < data[1]) { System.out.println(1); } else { if (data[0] > data[1]) { System.out.println(2); } else { System.out.println(3); } } } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
25099a48e3bb902640643e65fc5e6deb
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
//ღ(¯`◕‿◕´¯) ♫ ♪ ♫ YuSuF ♫ ♪ ♫ (¯`◕‿◕´¯)ღ import java.util.*; public class Two_Elevators { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t-- > 0) { int a = in.nextInt(); int b = in.nextInt(); int c = in.nextInt(); if (a == 1) { System.out.println("1"); } else { if (c > b) { int secondElevator = c - b; secondElevator += c - 1; int firstElevator = a - 1; if (firstElevator == secondElevator) { System.out.println("3"); } else { if (firstElevator < secondElevator) { System.out.println("1"); } else { System.out.println("2"); } } } else { int secondElevator = b - c; secondElevator += c - 1; int firstElevator = a - 1; if (firstElevator == secondElevator) { System.out.println("3"); } else { if (firstElevator < secondElevator) { System.out.println("1"); } else { System.out.println("2"); } } } } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
54f0f24bf2777199bceb6183c955807e
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class A_Two_Elevators { public static void main(String[]args) { Scanner x=new Scanner (System.in); int t=x.nextInt(); while(t-->0) { int a=x.nextInt(); int b=x.nextInt(); int c=x.nextInt(); int g=0,h=0; if(a==1) g=0; else g=a-1; if(c==1) h=b-c; else h=(int)Math.abs(b-c)+(int)Math.abs(c-1); if(g<h) System.out.println("1"); else if(h<g) System.out.println("2"); else System.out.println("3"); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
1f9730894cd116e97ebba03ed997bcc2
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class A { public static int solve(int a, int b, int c) { int time1 = Math.abs(a - 1); int time2 = Math.abs(b - c) + Math.abs(c - 1); if (time1 == time2) { return 3; } else if (time1 > time2) { return 2; } else { return 1; } } public static void main(String[] args) { Scanner in = new Scanner(System.in); int t, a, b, c; t = in.nextInt(); for (int i=0; i<t; i++) { a = in.nextInt(); b = in.nextInt(); c = in.nextInt(); int result = solve(a, b, c); System.out.println(result); } in.close(); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
a62bf247cd646625a7c6e11828fc14f1
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class question { public static void main(String[] args) throws java.lang.Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while(t-->0) { String st[] = br.readLine().trim().split(" "); int a = Integer.parseInt(st[0]); int b = Integer.parseInt(st[1]); int c = Integer.parseInt(st[2]); if(a-1<Math.abs(b-c)+c-1) { System.out.println("1"); } else if(a-1>Math.abs(b-c)+c-1) { System.out.println("2"); } else System.out.println("3"); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
e4ead2ed1f8e17fb9d9c4d47ad28d846
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
//============================================================================ //Everyone has a different way of thinking, so God Created us // Hope You Respect My Way..,Thank You ): // Author : Murad // Name : Codeforces.cpp & Atcoder.cpp // Description : Problem name //============================================================================/ import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in= new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); int t=in.nextInt(); while(t-->0){ long a=in.nextLong(),b=in.nextLong(),c=in.nextLong(); long cnt1=a-1; long cnt2=0; if(b>c){ cnt2=b-1; } else{ cnt2=Math.abs(b-c)+Math.abs(c-1); } if(cnt1==cnt2){ out.println(3); }else if(cnt1<cnt2)out.println(1); else out.println(2); } out.flush(); } static class NumberTheory{ public static long gcd(long a,long b){ long c; while (a != 0) { c = a; a = b % a; b = c; } return b; } } static class Pair implements Comparable<Pair> { long x; long y; Pair(long x, long y) { this.x = x; this.y = y; } @Override public int compareTo(Pair o) { if(x-o.x==0)return Math.toIntExact(y - o.y); return Math.toIntExact(x - o.x); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public long[] readLongArray(int n) { long[] x = new long[n]; for (int i = 0; i < n; i++) { x[i] = nextLong(); } return x; } public int[] readIntArray(int n) { int[] x = new int[n]; for (int i = 0; i < n; i++) { x[i] = nextInt(); } return x; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
efb091b51ed490a99564d7191366eacc
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0 ; i < t ;i++){ int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); a = Math.abs(a-1); int temp = 0; temp = Math.abs(c - b) + Math.abs(c - 1); // if(b > c){ // temp = Math.abs(b - 1); // }else{ // temp = 2*Math.abs(b - c); // } if(a < temp){ System.out.println("1"); }else if(temp < a){ System.out.println("2"); }else{ System.out.println("3"); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
0462699af0a83ed349664287a4b875a7
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; import java.util.*; public class Elevators{ static int helper(int a, int b, int c){ int ans1 = Math.abs(a-1); int ans2 = Math.abs(c-b) + Math.abs(c-1); if(ans1 < ans2){ return 1; }else if(ans2 < ans1){ return 2; } return 3; } public static void main(String args[]){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i < t; i++){ int a, b, c; a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); int ans = helper(a, b, c); System.out.println(ans); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
c0b1e89f6ab723623924693408c6ebb3
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; public class Main { static void out(int a,int b,int c) { int c1=0; int c2=0; c1=a-1; //System.out.println("c1="+c1); if(b>c) { c2=b-c; c2=c2+c-1; //System.out.println("c2="+c2); } if(c>b) { c2=c-b; c2=c2+c-1; //System.out.println("c2="+c2); } if(b==c) { c2=b-1; //System.out.println("c2="+c2); } if(c1<c2) System.out.println("1"); if(c2<c1) System.out.println("2"); if(c1==c2) System.out.println("3"); } public static void main(String[] args)throws IOException { InputStreamReader Ir=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(Ir); int a=Integer.parseInt(br.readLine()); String[] k=new String[a]; int[][] b=new int[a][3]; String[] splitStr; for(int i=0;i<a;i++) {k[i]=br.readLine(); splitStr= k[i].trim().split("\\s+"); for(int j=0;j<3;j++) { b[i][j]=Integer.parseInt(splitStr[j]); } } for(int i=0;i<a;i++) { out(b[i][0],b[i][1],b[i][2]); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
858b3e57077adc1963e1ce8e0814a8ad
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class sorting { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t>0) { int first=sc.nextInt(); int second=sc.nextInt(); int floor=sc.nextInt(); if(first==1) { System.out.println(1); }else { int one=Math.abs(first-1); int two=0; if(floor==1) two=Math.abs(second-1); else two=Math.abs(second-floor)+Math.abs(floor-1); if(one==two) System.out.println(3); else { if(two>one) System.out.println(1); else System.out.println(2); } //System.out.println(two); //System.out.println(one); } t--; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
977bd3634564c1c13def36b3afe04b65
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner scanner = new Scanner(System.in)) { int count = scanner.nextInt(); int[][] input = getInput(count, scanner); for (int i = 0; i < count; i++) { int a = input[i][0]; int b = input[i][1]; int c = input[i][2]; int secondWay = Math.abs(b - c) + c; int res = a < secondWay ? 1 : (a == secondWay ? 3 : 2); System.out.println(res); } } } private static int[][] getInput(int count, Scanner scanner) { int[][] input = new int[count][]; for (int i = 0; i < count; i++) { input[i] = new int[3]; input[i][0] = Integer.parseInt(scanner.next()); input[i][1] = Integer.parseInt(scanner.next()); input[i][2] = Integer.parseInt(scanner.next()); } return input; } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
5c0966d33c2f0504bd6ccff20fead5ce
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Sulution { static List<String> res=new ArrayList<>(); public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while (t-->0) { int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); if((a-1)<(Math.abs(b-c)+Math.abs(c-1))) { System.out.println(1); } else if((a-1)>(Math.abs(b-c)+Math.abs(c-1))) { System.out.println(2); } else { System.out.println(3); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
f09ea3959f0818164cfa09029760fcf0
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { final static int mod = 1000000007; final static String yes = "YES"; final static String no = "NO"; public static void main(String[] args) throws Exception { FastReader sc = new FastReader(); int t = sc.nextInt(); outer: while (t-- > 0) { int f = sc.nextInt(); int f1 = sc.nextInt(); int f2 = sc.nextInt(); int time1 = Math.abs(f - 1); int time2 = Math.abs(f2 - f1) + Math.abs(f2 - 1); if (time1 < time2) { System.out.println(1); } else if (time1 == time2) { System.out.println(3); } else { System.out.println(2); } } } static long getVal(char[] c) { long ans = 0; for (int i = 1; i < c.length; i++) { ans += ((c[i - 1] - '0') * 10) + (c[i] - '0'); } return ans; } static boolean check(int x, int y, char[] s, char[] c) { int i = x, j = y; int n = c.length; while (i >= 0 && j < n && s[i] == c[j]) { i--; j++; } return j == n ? true : false; } public static class Pair { // public static class Pair implements Comparator<Pair> { int x; int y; public Pair(int x, int y) { this.x = x; this.y = y; } /* * Write the below Comparator function inside Arrays.sort or * Collections.sort like: * Arrays.sort(k, new Comparator<Pair>() { * * @Override * public int compare(Pair obj1, Pair obj2) x{ * if (obj1.x == obj2.x) { * return obj1.y - obj2.y; * } * return obj1.x - obj2.x; * } * }); */ } public static class orderPair implements Comparable<orderPair> { int val; int pos; public orderPair(int val, int pos) { this.val = val; this.pos = pos; } @Override public int compareTo(orderPair obj) { if (this.val == obj.val) return this.pos - obj.pos; return this.val - obj.val; } } static int dfs(int[] a, boolean[] visited, int i) { if (visited[i]) { return i + 1; } visited[i] = true; return dfs(a, visited, a[i] - 1); } static void sortLong(long[] a) // check for long { ArrayList<Long> l = new ArrayList<>(); for (long i : a) l.add(i); Collections.sort(l); for (int i = 0; i < a.length; i++) a[i] = l.get(i); } static void sortInt(int[] a) // check for int { ArrayList<Integer> l = new ArrayList<>(); for (int i : a) l.add(i); Collections.sort(l); for (int i = 0; i < a.length; i++) a[i] = l.get(i); } public static boolean isSorted(int[] nums, int n) { for (int i = 1; i < n; i++) { if (nums[i] < nums[i - 1]) return false; } return true; } public static boolean isPalindrome(String s) { StringBuilder sb = new StringBuilder(s); return s.equals(sb.reverse().toString()); } static long kadane(long A[]) { long lsum = A[0], gsum = 0; gsum = Math.max(gsum, lsum); for (int i = 1; i < A.length; i++) { lsum = Math.max(lsum + A[i], A[i]); gsum = Math.max(gsum, lsum); } return gsum; } public static void backtrack(String[] letters, int index, String digits, StringBuilder build, List<String> result) { if (build.length() >= digits.length()) { result.add(build.toString()); return; } char[] key = letters[digits.charAt(index) - '2'].toCharArray(); for (int j = 0; j < key.length; j++) { build.append(key[j]); backtrack(letters, index + 1, digits, build, result); build.deleteCharAt(build.length() - 1); } } public static String stringMultiply(String s, int k) { int n = s.length(); int rep = k % n == 0 ? k / n : k / n + 1; s = s.repeat(rep); return s.substring(0, k); } public static int diglen(Long y) { int a = 0; while (y != 0L) { y /= 10; a++; } return a; } static String reverseString(String str) { StringBuilder input = new StringBuilder(); return input.append(str).reverse().toString(); } static void printArray(int[] nums) { for (int i = 0; i < nums.length; i++) { System.out.print(nums[i] + "->"); } System.out.println(); } static void printLongArray(long[] nums) { for (int i = 0; i < nums.length; i++) { System.out.print(nums[i] + "->"); } System.out.println(); } static void printPair(orderPair[] a) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < a.length; i++) { System.out.print(a[i].val + "->"); sb.append(a[i].pos + "->"); } System.out.println(); System.out.println(sb.toString()); } static long factorial(int n, int b) { if (n == b) return 1; return n * factorial(n - 1, b); } static int lcm(int ch, int b) { return ch * b / gcd(ch, b); } static int gcd(int ch, int b) { return b == 0 ? ch : gcd(b, ch % b); } static double ceil(double n, double k) { return Math.ceil(n / k); } static int sqrt(double n) { return (int) Math.sqrt(n); } static class FastReader { BufferedReader br; StringTokenizer st; // StringTokenizer() is used to read long strings public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
d786a4dff68f7d567a95e0aa1ea657fa
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); float summa = 0; for (int i = 0; i < t; i++) { int a = input.nextInt(); int b = input.nextInt(); int c = input.nextInt(); getAns(a,b,c); } } private static void getAns(int a,int b, int c) { if (a == 1) System.out.println(1); else { int dif = Math.abs(b - c) + c; if (a > dif) System.out.println(2); else if (a < dif) System.out.println(1); else System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
db5ffd32fd9f9ee14a2ab7833828f649
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class TwoElevators { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); int n = scan.nextInt(); for (int i= 0; i<n;i++) { int a = scan.nextInt(); int b= scan.nextInt(); int c= scan.nextInt(); fastest(a,b,c); } } public static void fastest(int a, int b, int c) { int tE1 = Math.abs(a-1); int tE2 = Math.abs(c-b) + Math.abs(c-1); if (tE2< tE1) { System.out.println("2"); } else if (tE2> tE1) { System.out.println("1"); } else { System.out.println("3"); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
d08138dbbec0b09027dda8a6cdffa4d4
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++){ int k=0; int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); if(a==1){ k=1; } else{ int p=Math.abs(b-c); int h=Math.abs(c-1); int m=p+h; h=Math.abs(a-1); if(m<h){ k=2; } else if(m>h){ k=1; } else{ k=3; } } System.out.println(k); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
dabd5aa662e774f2e37173e1e8951e87
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class r820{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int t1 = Math.abs(a-1); int t2 = Math.abs(c-b)+Math.abs(c-1); if(t1>t2) { System.out.println(2); }else if(t2>t1) { System.out.println(1); }else { System.out.println(3); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 11
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
e95c7ca077378e2a989635acd686364c
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class lesson1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); while( t != 0 ){ int a = input.nextInt(); int b = input.nextInt(); int c = input.nextInt(); int t1 = a - 1; int t2 = 0; if ( b > c ){ t2 = b - 1; } if( c > b ){ t2 = ( c - b ) * 2 + ( b - 1); } if ( t1 > t2 ){ System.out.println("2"); } else if( t1 < t2 ){ System.out.println("1"); } else{ System.out.println("3"); } t--; } input.close(); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
493b733824f2a7dffd01d3ab154d450b
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class CF_Elevator { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int w = sc.nextInt(); while(w-- > 0) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int cal1=a-1; int cal2=0; if(c>b) { cal2 = (c-b)*2 + b-1; }else if(b>c) { cal2 = b-1; } if(cal1 > cal2) { System.out.println("2"); }else if(cal2> cal1) { System.out.println("1"); }else if(cal2 == cal1) { System.out.println("3"); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
993d06bfedee1178637b172142bc53ef
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
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; import static java.lang.Math.*; public class TwoElevators implements Closeable { private InputReader in = new InputReader(System.in); private PrintWriter out = new PrintWriter(System.out); public void solve() { int T = in.ni(); while (T-- > 0) { int a = in.ni(), b = in.ni(), c = in.ni(); int T1 = a; int T2; if (b < c) { T2 = 2 * c - b; } else { T2 = b; } if (T1 < T2) { out.println(1); } else if (T1 > T2) { out.println(2); } else { out.println(3); } } } @Override public void close() throws IOException { in.close(); out.close(); } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int ni() { return Integer.parseInt(next()); } public long nl() { return Long.parseLong(next()); } public void close() throws IOException { reader.close(); } } public static void main(String[] args) throws IOException { try (TwoElevators instance = new TwoElevators()) { instance.solve(); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
0208970ca8aeabf636a485b6fc165ece
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here try { Scanner s = new Scanner(System.in); int t= s.nextInt(); for(int i=0; i<=t; i++){ int a = s.nextInt(); int b = s.nextInt(); int c = s.nextInt(); int x = Math.abs(a-1); int y; if(c>b){ y = (c-b)+(c-1); }else{ y = b-1; } if(x<y){ System.out.println("1"); }else if(x>y){ System.out.println("2"); }else{ System.out.println("3"); } } } catch(Exception e) { } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
efc0a811d3e0484db8004f30419079f1
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Codeforces { public static void main(String[] args) { Scanner in = new Scanner (System.in); long t=in.nextLong(); while(t>0) { int a [ ] = new int [ 3 ]; int c1=0 , c2=0 ; for(int i = 0 ; i < 3 ; i++) { a[i]=in.nextInt(); } c1=Math.abs(a[0]-1); if(a[2]>a[1]) { c2+=Math.abs(a[2]-a[1]); c2+=Math.abs(a[2]-1); } else if(a[2]<a[1]) { c2+=Math.abs(a[1]-1); } if(c1>c2) System.out.println(2); if(c1<c2) System.out.println(1); if(c1==c2) System.out.println(3); t--; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
cf24d563ed623fc17754a16dfc1fa3fa
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class App { public static void main(String[] args) { // test the structures here int t = 0; Scanner scanner = new Scanner(System.in); t = scanner.nextInt(); for (int i = 0; i < t; i++) { int a = 0; int b = 0; int c = 0; a = scanner.nextInt(); b = scanner.nextInt(); c = scanner.nextInt(); int x = Math.abs(c - b) + c; if (a == x) System.out.println(3); else if (a < x) System.out.println(1); else System.out.println(2); } scanner.close(); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
c5cdb0fe8352be1662e6e1167e25ca14
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); in.nextLine(); String[] chisla; for (int i = 0; i < t; i++){ String s = in.nextLine(); chisla = s.split(" "); int[] values = new int[] {Integer.parseInt(chisla[0]), Integer.parseInt(chisla[1]), Integer.parseInt(chisla[2])}; int path1, path2; path1 = Math.abs(values[0] - 1); path2 = Math.abs(values[2]-values[1])+Math.abs(values[2]-1); if (path1 == path2) System.out.println(3); else if (path1 < path2) System.out.println(1); else System.out.println(2); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
676fe6f4f32048c1b96fe74f4ab2032b
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt();in.nextLine(); String[] chisla; for (int i = 0; i < t; i++){ String s = in.nextLine(); chisla = s.split(" "); int[] values = new int[3]; int cc = 0; for (String chislo: chisla){ values[cc] = Integer.parseInt(chislo); cc++; } int path1, path2; path1 = Math.abs(values[0] - 1); path2 = Math.abs(values[2]-values[1])+Math.abs(values[2]-1); if (path1 == path2) System.out.println(3); else if (path1 < path2) System.out.println(1); else System.out.println(2); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
bc693405587f91ec6c94b4a99eb58fa6
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); String[] chisla = new String[t]; String a = in.nextLine(); for (int i = 0; i < t; i++){ String s = in.nextLine(); chisla = s.split(" "); int c3 = Integer.parseInt(chisla[2]); int c1 = Integer.parseInt(chisla[0]); int c2 = Integer.parseInt(chisla[1]); int path1, path2; path1 = Math.abs(c1 - 1); path2 = Math.abs(c3-c2)+Math.abs(c3-1); if (path1 == path2) System.out.println(3); else if (path1 < path2) System.out.println(1); else System.out.println(2); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
580ed0a39dad79eb4ff034c40e90919e
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; import java.util.*; public class Codechef { public static void main(String[] args)throws java.lang.Exception { FastReader input=new FastReader(); int testcases=input.nextInt(); while(testcases-->0){ int a=input.nextInt(); int b=input.nextInt(); int c=input.nextInt(); int time1=Math.abs(a-1); int time2=Math.abs(b-c)+Math.abs(c-1); if(time1>time2){ System.out.println(2); } else if(time2>time1){ System.out.println(1); } else{ System.out.println(3); } } } public static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { if(st.hasMoreTokens()){ str = st.nextToken("\n"); } else{ str = br.readLine(); } } catch (IOException e) { e.printStackTrace(); } return str; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
919355443d0634c0265dba61e5fde6a2
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class TwoElevators { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int f=a-1; int s=(b<c)?c-b+c-1:b-1; System.out.println((s==f)?"3":((s<f)?"2":"1")); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
eec72f80927d1244bd5472a794555fde
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; import java.lang.Math; public class TwoElevators { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int testCases = scanner.nextInt(); for(int i = 0; i < testCases; i++){ int currentFloor1st = scanner.nextInt(); int currentFloor2nd = scanner.nextInt(); int toGoFloor2nd = scanner.nextInt(); int time1st = calculateFirstElevatorTime(currentFloor1st); int time2nd = calculateSecondElevatorTime(currentFloor2nd, toGoFloor2nd); int bestChoice = time1st > time2nd ? 2 : (time1st == time2nd ? 3 : 1); System.out.println(bestChoice); } } public static int calculateFirstElevatorTime(int currentFloor){ return currentFloor - 1; } public static int calculateSecondElevatorTime(int currentFloor, int toGoFloor){ return Math.abs(currentFloor - toGoFloor) + (toGoFloor - 1); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
e8e2d1fcec187dc2e0ea124c7818c26e
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; import java.lang.Math; public class Main { public static int TEST_CASES = 3; private static int[] datas; public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int testCases = scanner.nextInt(); datas = new int[testCases]; for(int i = 0; i < testCases; i++){ int currentFloor1st = scanner.nextInt(); int currentFloor2nd = scanner.nextInt(); int toGoFloor2nd = scanner.nextInt(); int time1st = calculateFirstElevatorTime(currentFloor1st); int time2nd = calculateSecondElevatorTime(currentFloor2nd, toGoFloor2nd); int bestChoice = time1st > time2nd ? 2 : (time1st == time2nd ? 3 : 1); datas[i] = bestChoice; } for(int j : datas){ System.out.println(j); } } public static int calculateFirstElevatorTime(int currentFloor){ return currentFloor - 1; } public static int calculateSecondElevatorTime(int currentFloor, int toGoFloor){ return Math.abs(currentFloor - toGoFloor) + (toGoFloor - 1); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
5b684dbf0ddf9efe27245f78644e6141
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class TwoElevator { // 8:30pm public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int ele1 = Math.abs(a-1); int ele2 = 0; if(c==1){ ele2 = Math.abs(b-c); }else ele2 = Math.abs(b-c) + Math.abs(c-1); if(ele1<ele2) System.out.println(1); else if(ele1>ele2) System.out.println(2); else System.out.println(3); } sc.close(); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
09cf7fbce89abe4568f49e2f562d98ea
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(int i=0;i<n;i++){ int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); int diff=a-1; int diff1=Math.abs(c-b)+c-1; if(diff1==diff){ System.out.println(3); } else if(diff>diff1){ System.out.println(2); } else{ System.out.println(1); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
a1a2a882a2e49b6dfd42b9f5ad5e64bd
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int i = 0; i < t; i++) { int a = in.nextInt(); int b = in.nextInt(); int c = in.nextInt(); if(a - 1 < Math.abs(b - c) + (c - 1)) { System.out.println(1); } else if(a - 1 > Math.abs(b - c) + (c - 1)) { System.out.println(2); } else { System.out.println(3); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
aaac7c14161ab21b9f9c8690f37f93ab
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class elevator { public static void main(String[] args) { Scanner s = new Scanner(System.in); int tc = s.nextInt(); while(tc-->0){ int a = s.nextInt(); int b =s.nextInt(); int c = s.nextInt(); b = Math.abs(c-b)+c; if(a<b) System.out.println(1); else if(b<a) System.out.println(2); else System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
211d91429bec3d303a4013195ce50c56
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Div3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int a = input.nextInt(); for (int i = 0; i < a; i++) { int first = input.nextInt(); int second = input.nextInt(); int secondgo = input.nextInt(); if (Math.abs(secondgo - second) + (secondgo - 1) == first - 1) { System.out.println("3"); } if (Math.abs(secondgo - second) + (secondgo - 1) > first - 1) { System.out.println("1"); } if (Math.abs(secondgo - second) + (secondgo - 1) < first - 1) { System.out.println("2"); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
a0e8a3f1b17b0075f536c7db583963ba
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Lift { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); int h=Math.abs(c-b)+Math.abs(c-1); if(a-1<h){ System.out.println(1); } if(a-1==h){ System.out.println(3); } if(h<a-1){ System.out.println(2); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
88692f4b3b540d610196468290364f91
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; import java.lang.*; public class cp1 { public static void main(String[] args) { //write your code here Scanner sc = new Scanner(System.in); int t=sc.nextInt(); for (int tt = 0; tt < t; tt++) { int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); int x = a-1; int y=0; if (c > b) { y = c-b + c-1; }else if(b>c){ y=b-c + c-1; } if(a==1){ System.out.println("1"); continue; } if(x<y){ System.out.println("1"); }else if(x>y){ System.out.println("2"); }else if(x==y){ System.out.println("3"); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
720a3169213414e30d69daa0e0a92923
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc= new Scanner(System.in); int t= sc.nextInt(); while(t-->0) { int a,b,c; a=sc.nextInt(); b=sc.nextInt(); c=sc.nextInt(); int ans1=Math.abs(a-1); int ans2=Math.abs(Math.abs(b-c)+ Math.abs(c-1)); if(ans1<ans2) System.out.println(1); else if(ans1>ans2) System.out.println(2); else System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
4fa31bd8a9543acc849d1ea984120356
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class A_contest1 { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { // TODO Auto-generated method stub int t = sc.nextInt(); int a, b, c, a1, b1; while (t>0) { a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); if (a == 1) { System.out.println(1); } else { int diff1 = 0; if (a > 1) { diff1 = a - 1; } int diff2; int tot = 0; if (b > c) { diff2 = b - c; tot = diff2 + (c - 1); } else { diff2 = c - b; tot = diff2 + (c - 1); } if (tot == diff1) { System.out.println(3); } else if (tot < diff1) { System.out.println(2); } else { System.out.println(1); } diff1 = 0; diff2 = 0; tot = 0; } t--; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
39d7973c3af3fc8186cfc0fb7246f2e2
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class decelaration { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0){ int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if (c == 1){ if ((a - 1) < (b - c)){ System.out.println(1); } else if ((a - 1) > (b - c)){ System.out.println(2); } else { System.out.println(3); } } else { int tot = Math.abs(b - c); tot += c - 1; if ((a - 1) < tot){ System.out.println(1); } else if ((a - 1) > tot){ System.out.println(2); } else { System.out.println(3); } } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
fee8f276e1e418ea72a8527067d7a38b
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class rough { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int t1 = Math.abs(a-1); int t2 = Math.abs(b-c)+Math.abs(c-1); if(t1>t2) System.out.println(2); else if (t1<t2) System.out.println(1); else System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
5373c9c277ca90d90291cc1ded85803e
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class rough { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int t1 = Math.abs(a-1); int t2 = Math.abs(b-c)+Math.abs(c-1); if(t1>t2) System.out.println(2); else if (t1<t2) System.out.println(1); else System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
8ee57cf7d11f54b0130bd56dd82a65b5
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class syntax { public static void main(String[] args) { // Java syntax: // Variables: boolean(true/false), int(an integer), double(fractional number), char(a character), String(a sequence of characters). // User's input: "java.util.Scanner" at the start of the code to import scanner class into the program, "Scanner scanner = new Scanner(System.in)" to create a scanner function, so user can enter the information, "var any = scanner.nextVar()" to user so he can enter any kind of variable. // Expression: operands and operators. Operands is: values, variables, numbers, quantity. Operators is: + - * / %. // GUI: "javax.swing.JOptionPane" at the start of the code to import GUI into the program, "String name = JOptionPane.showInput/Dialog", if any other variable: "variable any = Variable.parseVar(GUI command)" // Math class: "Math.max"; "Math.min"; "Math.abs"; "Math.sqrt"; "Math.round"; "Math.ceil"; "Math.floor". // Random numbers: "java.util.Random" at the start of the code to import Random class into the program, "Random random = new Random" to create a random value, so we can generate a random answers for variables, "var any = random.nextVar()" to user so he can enter any kind of variable to be randomly generated. // If statement: "if()"; "else()"; "else if()". // Switch statement: "switch(any); { // case "some 1": command 1 // break // case "some 2": command 2 // break // ... // case "some n": command n // break // default: default command // }" // Logical operators: used to connect two or more expressions, they're: "&&" (AND) both conditions must be true; "||" (OR) either condition must be true; "!" (NOT) reverses boolean value of condition. // While loop = executes a block of code as long as it's condition remains true. // For loop = executes a block of code a limited amount of time. // Nested loop = a loop inside of another loop. // Array = used to store multiple values in a single variable. (To pick random element of an array: int n = (int)Math.floor(Math.random() * waifu.length); ). // ArrayList = a resizable array. Scanner scanner = new Scanner(System.in); int input = scanner.nextInt(); for(int i=0; i<input; i++) { int a = scanner.nextInt(); int b = scanner.nextInt(); int c = scanner.nextInt(); int xa = a; int ya = 1; int timefora = Math.abs(xa-ya); int xb = b; int yb = c; int timeforb = Math.abs(xb-yb); int timeforc = Math.abs(yb-1); int timefor2 = timeforb+timeforc; if(timefora<timefor2) { System.out.println('1'); } else if(timefora>timefor2) { System.out.println('2'); } else if(timefora==timefor2) { System.out.println('3'); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
ef7a34a12febfde50096bba8b0ae567c
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
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 { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out)); int t; t=sc.nextInt(); first: while(t-->0) { int res,fill,place; long x=sc.nextLong(); long y=sc.nextLong(); long z=sc.nextLong(); if(z==1) { if(x>y) {System.out.println(2); continue;} else if(y>x) {System.out.println(1); continue;} else { System.out.println(3); continue; } } if(x-1>Math.abs(y-z)+z-1) { System.out.println(2); continue; } else if(x-1<Math.abs(y-z)+z-1) { System.out.println(1); continue; } System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
cc16fdd08dda3e177b2a60b3aafdce37
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; import java.math.*; public class Solution { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); int a1=Math.abs(b-c)+Math.abs(c-1); int a2=Math.abs(a-1); if(a1>a2) System.out.println("1"); else if(a2>a1) System.out.println("2"); else System.out.println("3"); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
7644ba8161fffc9a3797942c87464886
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[]args) { Scanner sc=new Scanner(System.in); long n1,n2; int n=sc.nextInt(); for(int i=1;i<=n;i++) { long a=sc.nextLong(); long b=sc.nextLong(); long c=sc.nextLong(); n1=Math.abs(b-c)+Math.abs(c-1); n2=Math.abs(a-1); if(n1>n2) { System.out.println("1"); } else if(n2>n1) { System.out.println("2"); } else { System.out.println("3"); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
331afcb5872f3e17c37b969037f999c7
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class q1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); int t1=0; int t2=0; if(a==1) t1=0; else t1=a-1; if(b>c) t2=b-1; else t2=(c-b)+(c-1); if(t1>t2) System.out.println(2); else if(t1<t2) System.out.println(1); else System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
27f66844e1e87df7d34df208b9d8d411
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.lang.System.*; public class TwoElevators implements Runnable { private final void process() throws IOException { // InputReader input = new InputReader(new FileReader(System.getenv("INPUT"))); // PrintWriter output = new PrintWriter(new BufferedOutputStream(new FileOutputStream(System.getenv("OUTPUT")))); InputReader input = new InputReader(in); PrintWriter output = new PrintWriter(new BufferedOutputStream(out)); short test = input.nextShort(); while (test-- > 0) { int a = input.nextInt() - 1, b = input.nextInt(), c = input.nextInt(); int optB = b < c ? (c - b) + (c - 1) : b - 1; if (a == optB) { output.println(3); } else if (a < optB) { output.println(1); } else { output.println(2); } } input.close(); output.close(); } @Override public void run() { try { process(); } catch (IOException ignored) {} } public static void main(String... args) throws IOException { new Thread(null, new TwoElevators(), "Main", 1 << 26).start(); } private final void printArr(PrintWriter output, short...arr) { output.println(Arrays.toString(arr).replaceAll("\\[|]|, ", " ").trim()); } private final void printArr(PrintWriter output, int...arr) { output.println(Arrays.toString(arr).replaceAll("\\[|]|, ", " ").trim()); } private final void printArr(PrintWriter output, double...arr) { output.println(Arrays.toString(arr).replaceAll("\\[|]|, ", " ").trim()); } private final void printArr(PrintWriter output, long...arr) { output.println(Arrays.toString(arr).replaceAll("\\[|]|, ", " ").trim()); } private final void printArr(PrintWriter output, char...arr) { output.println(Arrays.toString(arr).replaceAll("\\[|]|, ", " ").trim()); } private final void printArr(PrintWriter output, String...arr) { output.println(Arrays.toString(arr).replaceAll("\\[|]|, ", " ").trim()); } } class InputReader { private StringTokenizer token; private BufferedReader buffer; public InputReader(InputStream stream) { buffer = new BufferedReader(new InputStreamReader(stream)); } public InputReader(FileReader reader) throws FileNotFoundException { buffer = new BufferedReader(reader); } public final String next() throws IOException { while (token == null || !token.hasMoreTokens()) token = new StringTokenizer(buffer.readLine()); return token.nextToken(); } public final String nextLine() throws IOException { return buffer.readLine(); } public final byte nextByte() throws IOException { return Byte.parseByte(next()); } public final short nextShort() throws IOException { return Short.parseShort(next()); } public final int nextInt() throws IOException { return Integer.parseInt(next()); } public final long nextLong() throws IOException { return Long.parseLong(next()); } public final double nextDouble() throws IOException { return Double.parseDouble(next()); } public final char nextChar() throws IOException { return next().charAt(0); } public final boolean nextBoolean() throws IOException { return Boolean.parseBoolean(next()); // return Boolean.getBoolean(next()); // return Boolean.valueOf(next()); } public int[] readIntArray(int n) throws IOException { int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = nextInt(); return arr; } public int[] readIntArray() throws IOException { return java.util.Arrays.stream(nextLine().split("\\s+")). mapToInt(Integer::parseInt).toArray(); } public long[] readLongArray(int n) throws IOException { long[] arr = new long[n]; for (int i = 0; i < n; i++) arr[i] = nextLong(); return arr; } public long[] readLongArray() throws IOException { return java.util.Arrays.stream(nextLine().split("\\s+")). mapToLong(Long::parseLong).toArray(); } public double[] readDoubleArray(int n) throws IOException { double[] arr = new double[n]; for (int i = 0; i < n; i++) arr[i] = nextDouble(); return arr; } public double[] readDoubleArray() throws IOException { return java.util.Arrays.stream(nextLine().split("\\s+")). mapToDouble(Double::parseDouble).toArray(); } public char[] readCharArray() throws IOException { return nextLine().toCharArray(); } public String[] readStringArray(int n) throws IOException { String[] arr = new String[n]; for (int i = 0; i < n; i++) arr[i] = next(); return arr; } public String[] readStringArray() throws IOException { return nextLine().split("\\s+"); } public boolean ready() throws IOException { return buffer.ready(); } public void close() throws IOException { buffer.close(); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
80632fef1a1243b36d9ae6bcf96007b0
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class elevator { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(); if(a==1) { System.out.println("1"); } else { int f,s; f=Math.abs(a-1); if(b<c) s=Math.abs(c-b)+Math.abs(c-1); else s=Math.abs(b-1); if(f<s) System.out.println("1"); else if(s<f) System.out.println("2"); else System.out.println("3"); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
a4008188475c7a9a2cacf00ac77864b0
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class main2 { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader(String file_name) throws IOException { din = new DataInputStream( new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String readLine() throws IOException { byte[] buf = new byte[64]; // line length int cnt = 0, c; while ((c = read()) != -1) { if (c == '\n') { if (cnt != 0) { break; } else { continue; } } buf[cnt++] = (byte)c; } return new String(buf, 0, cnt); } public int nextInt() throws IOException { int ret = 0; byte c = read(); while (c <= ' ') { c = read(); } boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public long nextLong() throws IOException { long ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public double nextDouble() throws IOException { double ret = 0, div = 1; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (c == '.') { while ((c = read()) >= '0' && c <= '9') { ret += (c - '0') / (div *= 10); } } if (neg) return -ret; return ret; } private void fillBuffer() throws IOException { bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); if (bytesRead == -1) buffer[0] = -1; } private byte read() throws IOException { if (bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } public void close() throws IOException { if (din == null) return; din.close(); } } public static void main(String[] args) throws IOException { Reader s = new Reader(); int test =s.nextInt(); for(int i = 0;i<test;i++) { long a=s.nextInt(); long b=s.nextInt(); long c=s.nextInt(); long d=Math.abs(b-c); long e=Math.abs(c-1); if(Math.abs(a-1)==Math.abs(d+e)) System.out.println("3"); else if(Math.abs(d+e)>Math.abs(a-1)) System.out.println("1"); else System.out.println("2"); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
bc615a80dfb37fae716b7603973db836
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
//package com.company; import java.util.*; public class Codeforces { static int gcd(int a,int b){ if (a == 0){ return b; } return gcd(b % a,a); } static int lcm(int a,int b){ return ((a * b)/gcd(a,b)); } public static void main(String[] args) { Scanner lta = new Scanner(System.in); int t = lta.nextInt(); while (t-- >0) { int a = lta.nextInt(); int b = lta.nextInt(); int c = lta.nextInt(); if (t < 0) { if (a == 1) { System.out.println(1); } else if (a == 3 && b == 1 && c == 2) { System.out.println(3); } else { System.out.println(2); } } else { int i = Math.abs(b - c) + Math.abs(c - 1); if (i < Math.abs(a - 1)){ System.out.println(2); } else if (i > Math.abs(a - 1)){ System.out.println(1); } else { System.out.println(3); } } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
4bc26629ba9650418de31ecd4b1d4da6
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public final class CF{ public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t != 0) { int a = s.nextInt(); int b = s.nextInt(); int c = s.nextInt(); int k = Math.abs(1 - c) + Math.abs(c - b); int m = Math.abs(1 - a); if(m > k) System.out.println(2); else if(k > m) System.out.println(1); else System.out.println(3); t--; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
11355cdf9818f0b702f8cb9aec17b201
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; import static java.lang.System.*; import static java.lang.System.out; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Arrays.sort; import static java.util.Collections.shuffle; import static java.util.Collections.sort; public class Solution { private final static FastScanner scanner = new FastScanner(); private final static int mod = (int) 1e9+7; private final static int max_value = Integer.MAX_VALUE; private final static int min_value = Integer.MIN_VALUE; private final static String endl = "\n"; private static void solve() { int a = ii(), b = ii(), c = ii(); int x = b<c?(c+c-b):b; if (a<x) pl(1); else if (a == x) pl(3); else pl(2); } public static void main(String[] args) { int t = ii(); while (t-->0) solve(); } private static void swap(int[] a, int i, int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } private static void swap(int[] a, int[] b, int i) { int temp = a[i]; a[i] = b[i]; b[i] = temp; } private static int f(int x) { String a = x+""; return a.length(); } private static void iota(int[] a, int x) { for (int i = 0; i<a.length; i++) a[i] = x++; } private static void reverse(int[] a) { int[] b = new int[a.length]; int k = 0; for (int i = a.length-1; i>=0; i--) { b[k++] = a[i]; } System.arraycopy(b, 0, a, 0, b.length); } private static int[] rai(int n) { return scanner.readArray(n); } private static String[] ras(int n) { return IntStream.range(0, n).mapToObj(i -> s()).toArray(String[]::new); } private static int lcm (int a, int b) { return a / gcd (a, b) * b; } private static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } private static int ii() { return scanner.nextInt(); } private static long l() { return scanner.nextLong(); } private static double d() { return scanner.nextDouble(); } private static String s() { return scanner.next(); } private static int toInt(String s) { return Integer.parseInt(s); } private static ArrayList<Integer> list() { return new ArrayList<>(); } private static HashSet<Integer> set() { return new HashSet<>(); } private static HashMap<Integer, Integer> map() { return new HashMap<>(); } private static int toInt(char c) { return Integer.parseInt(c+""); } private static<K> void pl(K a) { p(a+endl); } private static<K> void p(K a) { out.print(a); } private static void yes() { pl("YES"); } private static void no() { pl("NO"); } private static int max_a(int[] a) { int max = a[0]; for (int j : a) { if (j > max) { max = j; } } return max; } private static int min_a(int[] a) { int min = a[0]; for (int j : a) { if (j < min) { min = j; } } return min; } private static long sum(int[] a) { return stream(a).asLongStream().sum(); } private static void pl() { out.println(); } private static void printArray(long[] a) { StringBuilder builder = new StringBuilder(); for (long i : a) builder.append(i).append(' '); pl(builder); } private static void printArray(int[] a) { StringBuilder builder = new StringBuilder(); for (int i : a) builder.append(i).append(' '); pl(builder); } private static<K> void printArray(K[] a) { StringBuilder builder = new StringBuilder(); for (K i : a) builder.append(i).append(' '); pl(builder); } private static int reverseInteger(int k) { String a = k+"", res = ""; for (int i = a.length()-1; i>=0; i--) { res+=a.charAt(i); } return toInt(res); } private static int phi(int n) { int result = n; for (int i=2; i*i<=n; i++) if (n % i == 0) { while (n % i == 0) n /= i; result -= result / i; } if (n > 1) result -= result / n; return result; } private static int pow(int a, int n) { if (n == 0) return 1; if (n % 2 == 1) return pow(a, n-1) * a; else { int b = pow (a, n/2); return b * b; } } private static boolean isPrimeLong(long n) { BigInteger a = BigInteger.valueOf(n); return a.isProbablePrime(10); } private static boolean isPrime(long n) { return IntStream.iterate(2, i -> i * i <= n, i -> i + 1).noneMatch(i -> n % i == 0); } private static List<Integer> primes(int N) { int[] lp = new int[N+1]; List<Integer> pr = new ArrayList<>(); for (int i=2; i<=N; ++i) { if (lp[i] == 0) { lp[i] = i; pr.add(i); } for (int j = 0; j<pr.size() && pr.get(j)<=lp[i] && i*pr.get(j)<=N; ++j) lp[i * pr.get(j)] = pr.get(j); } return pr; } private static Set<Integer> toSet(int[] a) { return stream(a).boxed().collect(Collectors.toSet()); } private static int linearSearch(int[] a, int key) { return IntStream.range(0, a.length).filter(i -> a[i] == key).findFirst().orElse(-1); } private static<K> int linearSearch(K[] a, K key) { return IntStream.range(0, a.length).filter(i -> a[i].equals(key)).findFirst().orElse(-1); } static int upper_bound(int[] arr, int key) { int index = binarySearch(arr, key); int n = arr.length; if (index < 0) { int upperBound = abs(index) - 1; if (upperBound < n) return upperBound; else return -1; } else { while (index < n) { if (arr[index] == key) index++; else { return index; } } return -1; } } static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } } private static void stableSort(int[] a) { List<Integer> list = stream(a).boxed().sorted().toList(); setAll(a, list::get); } private static void psort(int[] arr, int n) { int min = min_a(arr); int max = max_a(arr); int range = max-min+1, i, j, index = 0; int[] count = new int[range]; for(i = 0; i<n; i++) count[arr[i] - min]++; for(j = 0; j<range; j++) while(count[j]-->0) arr[index++]=j+min; } private static void csort(int[] a, int n) { int max = max_a(a); int min = min_a(a); int range = max - min + 1; int[] count = new int[range]; int[] output = new int[n]; for (int i = 0; i < n; i++) { count[a[i] - min]++; } for (int i = 1; i < range; i++) { count[i] += count[i - 1]; } for (int i = n - 1; i >= 0; i--) { output[count[a[i] - min] - 1] = a[i]; count[a[i] - min]--; } arraycopy(output, 0, a, 0, n); } private static void csort(char[] arr) { int n = arr.length; char[] output = new char[n]; int[] count = new int[256]; for (int i = 0; i < 256; ++i) count[i] = 0; for (char c : arr) ++count[c]; for (int i = 1; i <= 255; ++i) count[i] += count[i - 1]; for (int i = n - 1; i >= 0; i--) { output[count[arr[i]] - 1] = arr[i]; --count[arr[i]]; } arraycopy(output, 0, arr, 0, n); } // Java Program to show segment tree operations like construction, // query and update static class SegmentTree { int[] st; // The array that stores segment tree nodes /* Constructor to construct segment tree from given array. This constructor allocates memory for segment tree and calls constructSTUtil() to fill the allocated memory */ SegmentTree(int[] arr, int n) { // Allocate memory for segment tree //Height of segment tree int x = (int) (Math.ceil(Math.log(n) / Math.log(2))); //Maximum size of segment tree int max_size = 2 * (int) Math.pow(2, x) - 1; st = new int[max_size]; // Memory allocation constructSTUtil(arr, 0, n - 1, 0); } // A utility function to get the middle index from corner indexes. int getMid(int s, int e) { return s + (e - s) / 2; } /* A recursive function to get the sum of values in given range of the array. The following are parameters for this function. st --> Pointer to segment tree si --> Index of current node in the segment tree. Initially 0 is passed as root is always at index 0 ss & se --> Starting and ending indexes of the segment represented by current node, i.e., st[si] qs & qe --> Starting and ending indexes of query range */ int getSumUtil(int ss, int se, int qs, int qe, int si) { // If segment of this node is a part of given range, then return // the sum of the segment if (qs <= ss && qe >= se) return st[si]; // If segment of this node is outside the given range if (se < qs || ss > qe) return 0; // If a part of this segment overlaps with the given range int mid = getMid(ss, se); return getSumUtil(ss, mid, qs, qe, 2 * si + 1) + getSumUtil(mid + 1, se, qs, qe, 2 * si + 2); } /* A recursive function to update the nodes which have the given index in their range. The following are parameters st, si, ss and se are same as getSumUtil() i --> index of the element to be updated. This index is in input array. diff --> Value to be added to all nodes which have i in range */ void updateValueUtil(int ss, int se, int i, int diff, int si) { // Base Case: If the input index lies outside the range of // this segment if (i < ss || i > se) return; // If the input index is in range of this node, then update the // value of the node and its children st[si] = st[si] + diff; if (se != ss) { int mid = getMid(ss, se); updateValueUtil(ss, mid, i, diff, 2 * si + 1); updateValueUtil(mid + 1, se, i, diff, 2 * si + 2); } } // The function to update a value in input array and segment tree. // It uses updateValueUtil() to update the value in segment tree void updateValue(int arr[], int n, int i, int new_val) { // Check for erroneous input index if (i < 0 || i > n - 1) { System.out.println("Invalid Input"); return; } // Get the difference between new value and old value int diff = new_val - arr[i]; // Update the value in array arr[i] = new_val; // Update the values of nodes in segment tree updateValueUtil(0, n - 1, i, diff, 0); } // Return sum of elements in range from index qs (query start) to // qe (query end). It mainly uses getSumUtil() int getSum(int n, int qs, int qe) { // Check for erroneous input values if (qs < 0 || qe > n - 1 || qs > qe) { System.out.println("Invalid Input"); return -1; } return getSumUtil(0, n - 1, qs, qe, 0); } // A recursive function that constructs Segment Tree for array[ss..se]. // si is index of current node in segment tree st int constructSTUtil(int arr[], int ss, int se, int si) { // If there is one element in array, store it in current node of // segment tree and return if (ss == se) { st[si] = arr[ss]; return arr[ss]; } // If there are more than one elements, then recur for left and // right subtrees and store the sum of values in this node int mid = getMid(ss, se); st[si] = constructSTUtil(arr, ss, mid, si * 2 + 1) + constructSTUtil(arr, mid + 1, se, si * 2 + 2); return st[si]; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
716468ba8a5cbd0d8ee00c78a7d9346f
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int i = 1; i <= t; i++) { int a=in.nextInt(),b=in.nextInt(),c=in.nextInt(); if(a<Math.abs(c-b)+c) System.out.println(1); else{ if(a==Math.abs(c-b)+c) System.out.println("3"); else System.out.println("2"); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
feca03a547400ad5e5e4fd1fe7fc9d26
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; import java.io.*; public class Main{ static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br=new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(st==null || !st.hasMoreTokens()){ try { st=new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt(){ return Integer.parseInt(next()); } long nextLong(){ return Long.parseLong(next()); } double nextDouble(){ return Double.parseDouble(next()); } String nextLine(){ String str=""; try { str=br.readLine().trim(); } catch (Exception e) { e.printStackTrace(); } return str; } } static class FastWriter { private final BufferedWriter bw; public FastWriter() { this.bw = new BufferedWriter(new OutputStreamWriter(System.out)); } public void print(Object object) throws IOException { bw.append("" + object); } public void println(Object object) throws IOException { print(object); bw.append("\n"); } public void close() throws IOException { bw.close(); } } public static void main(String[] args) { try { FastReader in=new FastReader(); FastWriter out = new FastWriter(); int testCases=in.nextInt(); while(testCases-- > 0){ int a = in.nextInt(); int b = in.nextInt(); int c = in.nextInt(); int time = Math.abs(b-c); int secondElevator = time + c; int min = Math.min(a,secondElevator); if(a < secondElevator){ System.out.println("1"); } else if(secondElevator < a){ System.out.println("2"); } else{ System.out.println("3"); } } out.close(); } catch (Exception e) { return; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
09e7b3ae1d830b89d7d16f14d2529f05
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
// ronin import java.io.*; import java.util.*; public class A { public void solve(int a, int b, int c, PrintWriter out) { int res = a - (Math.abs(c - b) + c); int ans = 3; if (res > 0) { ans = 2; } if (res < 0) { ans = 1; } out.println(ans); } public void read(FastScanner fastScanner, PrintWriter out) { int a, b, c, d, e, n; a = fastScanner.nextInt(); b = fastScanner.nextInt(); c = fastScanner.nextInt(); solve(a, b, c, out); } // int n = fastScanner.nextInt(); // while (n--> 0) { // } /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// public static boolean isLocal = false; public static void main(String[] args) { FastScanner fastScanner = new FastScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int N = fastScanner.nextInt(); while (N-- > 0) { new A().read(fastScanner, out); } out.println(); out.close(); if (isLocal) { try { new A().buildFile(); } catch (IOException e) { throw new RuntimeException(e); } } } static class FastScanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); public FastScanner() { if (isLocal) { try { File f = new File("src/B/input.txt"); this.br = new BufferedReader(new InputStreamReader(new FileInputStream(f))); } catch (FileNotFoundException e) { throw new RuntimeException(e); } } else { this.br = new BufferedReader(new InputStreamReader(System.in)); } } String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } } public void buildFile() throws IOException { File thisFile = new File("src/B/A.java"); String s = ""; try (FileReader reader = new FileReader(thisFile)) { int c; StringBuilder stringBuilder = new StringBuilder(); while ((c = reader.read()) != -1) { stringBuilder.append((char) c); } s = stringBuilder.toString(); } ///////////////////////////////////////////////////////////////////////////// s = s.replace("// cout", "// cout"); s = s.replace("// System.out.print", "// System.out.print"); s = s.replace("// cout", "// cout"); s = s.replace("// ronin", "// ronin"); s = s.replace("public static boolean isLocal = false;", "public static boolean isLocal = false;"); ////////////////////////////////////////////////////////////////////////////////////////////////////////// File file = new File("src/B/LastBuild.txt"); if (!file.exists()) { file.createNewFile(); } try (FileWriter writer = new FileWriter(file, false)) { writer.write(s); writer.flush(); } } /////// public <T> void sout(List<T> s) { for (T o : s) { // System.out.print(o + " "); } } public <T, V> void sout(Map<T, V> s) { for (T t : s.keySet()) { // System.out.println(t + "=" + s.get(s)); } } ///////// ///////// ///////// ///////// class Pair<V, T> { private V a; private T b; public Pair(V a, T b) { this.a = a; this.b = b; } public V getA() { return a; } public T getB() { return b; } public Pair<V, T> setA(V a) { this.a = a; return this; } public Pair<V, T> setB(T b) { this.b = b; return this; } @Override public String toString() { return new StringJoiner(", ", Pair.class.getSimpleName() + "[", "]") .add("a=" + a) .add("b=" + b) .toString(); } } //algs private boolean isEven(int a) { return (a & 1) == 0; } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
bdeffd93413993076d15e254e1326e8e
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static int sol(int a, int b, int c) { int res = a - (Math.abs(c - b) + c); if (res>0) { return 2; } if (res<0) { return 1; } return 3; } static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } } public static void main(String[] args) { FastScanner fastScanner = new FastScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int n = fastScanner.nextInt(); for (int i = 0; i < n; i++) { int a, b, c; a = fastScanner.nextInt(); b = fastScanner.nextInt(); c = fastScanner.nextInt(); out.println(sol(a, b, c)); } out.close(); } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
cabc3816bc1c95a98ba2cc5cea996a5e
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.lang.*; import java.util.*; public class Elevators { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); int a,b,c; while(t-->0) { a = in.nextInt(); b = in.nextInt(); c = in.nextInt(); if(Math.abs(a-1)>Math.abs(c-b)+Math.abs(1-c)) System.out.println(2); else if(Math.abs(a-1)<Math.abs(c-b)+Math.abs(1-c)) System.out.println(1); else System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
a3dd8f0760eb372f112e7f2297a7ca69
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); List<List<Integer>> list = new ArrayList<>(); for (int i = 0; i < num; i++) { List <Integer> tempList = new ArrayList<>(); for (int j = 0; j < 3; j++) { tempList.add(scanner.nextInt()); } list.add(tempList); } for (List<Integer> integers : list) { int n1 = integers.get(0) - 1; int n2 = Math.abs(integers.get(2) - integers.get(1)) + integers.get(2) - 1; if (n1 < n2) { System.out.println(1); } else if (n2 < n1) { System.out.println(2); } else { System.out.println(3); } } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
6a10bba3bc561234fba15484a936c7e6
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class Te2 { void elevator(int[]a1) { int[]ar=a1.clone(); int x=1; int a= ar[0]; int b= ar[1]; int c= ar[2]; if(b>c) { if((a-x)<((b-c)+(c-x))) { System.out.println("1"); } else if((a-x)>((b-c)+(c-x))) { System.out.println("2"); } else { System.out.println("3"); } } if(b<c) { if((a-x)<((c-b)+(c-x))) { System.out.println("1"); } else if((a-x)>((c-b)+(c-x))) { System.out.println("2"); } else { System.out.println("3"); } } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); //System.out.println("Enter the number of test cases:"); int t=sc.nextInt(); for(int i=0;i<t;i++) { int[] arr = new int[3]; for(int j=0;j<3;j++) { //System.out.println("Enter the floors:"); arr[j]=sc.nextInt(); } Te2 t1=new Te2(); t1.elevator(arr); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
7b9766ec477676f8cf30728569795e16
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Two_Elevator { static Scanner sc = new Scanner(System.in); public static int solve(int[] arr){ int a = arr[0]; int b = arr[1]; int c = arr[2]; if(a == 1) return a; int count1 = a - 1; int count2 = 0; if(b >= c){ count2 = b - 1; } else{ count2 += c + (c - b) - 1; } if(count1 < count2) return 1; else if(count1 > count2) return 2; else return 3; } public static void main(String[] args) { int t = Integer.parseInt(sc.nextLine()); int[] arr = new int[3]; for(int i = 0; i < t; i++) { arr[0] = sc.nextInt(); arr[1] = sc.nextInt(); arr[2] = sc.nextInt(); System.out.println(solve(arr)); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
e30010b2aa6f3f3320e72dea361af32d
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; public class practice { public static void main(String[] args) { Scanner get = new Scanner(System.in); int a = get.nextInt(); for(int b=1;b<=a;b++) { long x = get.nextLong(); long y = get.nextLong(); long z = get.nextLong(); long t1 = x-1; long m=(x-1); long d=Math.abs(y-z)+Math.abs(z-1); if(m>d) System.out.println(2); else if(m<d) System.out.println(1); else System.out.println(3); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
018820ed90f7ebf771085b0d82135109
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
// A. Two Elevators import java.util.Scanner; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String args[]){ Scanner scanner = new Scanner(System.in); int numTimes = scanner.nextInt(); // Will contain Lists of abc List<List<Integer>> array = new ArrayList<>(); // Input scanner.nextLine(); for (int i = 0; i < numTimes; i++) { String line = scanner.nextLine(); List<Integer> abc = getABC(line); array.add(abc); } // Output for (int i = 0; i < numTimes; i++) { System.out.println(getFastestElevator(array.get(i))); } } static List<Integer> getABC(String line){ List<Integer> list = new ArrayList<>(); String tempStr = ""; for (int i = 0; i < line.length(); i++) { Character ch = line.charAt(i); if (ch.compareTo(' ') == 0) { list.add(Integer.parseInt(tempStr)); tempStr = ""; } else if (i == line.length()-1) { list.add(Integer.parseInt(tempStr+line.charAt(i))); } else { tempStr += line.charAt(i); } } return list; } static int getFastestElevator(List<Integer> abc){ int a = abc.get(0); int b = abc.get(1); int c = abc.get(2); int firstElevatorDist = a - 1; int secondElevatorDist = Math.abs(b - c) + c - 1; if (firstElevatorDist < secondElevatorDist) { return 1; } else if (firstElevatorDist > secondElevatorDist) { return 2; } else { return 3; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
938a283188bf527e1c23647de85efdc3
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.Scanner; public class Ab { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int t = sc.nextInt(); while (t-- > 0) { solve(); } } private static void solve() { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); a--; b = Math.abs(b - c) + Math.abs(c - 1); if (a < b) { System.out.println("1"); } else if (b < a) { System.out.println("2"); } else { System.out.println("3"); } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output
PASSED
eeb651c9dbb04b2807745c76caaa9191
train_110.jsonl
1662993300
Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently on the floor $$$a$$$ (it is currently motionless), the second elevator is located on floor $$$b$$$ and goes to floor $$$c$$$ ($$$b \ne c$$$). Please note, if $$$b=1$$$, then the elevator is already leaving the floor $$$1$$$ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $$$1$$$. If you call the second one, then first it will reach the floor $$$c$$$ and only then it will go to the floor $$$1$$$. It takes $$$|x - y|$$$ seconds for each elevator to move from floor $$$x$$$ to floor $$$y$$$.Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
256 megabytes
import java.util.*; import java.io.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine().trim(); } catch (Exception e) { e.printStackTrace(); } return str; } // to read an array from input int[] nextIntArray() { return Arrays.stream(nextLine().split("\\s")).mapToInt(i -> Integer.parseInt(i)).toArray(); } long[] nextLongArray() { return Arrays.stream(nextLine().split("\\s")).mapToLong(i -> Long.parseLong(i)).toArray(); } double[] nextDoubleArray() { return Arrays.stream(nextLine().split("\\s")).mapToDouble(i -> Double.parseDouble(i)).toArray(); } } static class FastWriter { private final BufferedWriter bw; public FastWriter() { this.bw = new BufferedWriter(new OutputStreamWriter(System.out)); } public void print(Object object) throws IOException { bw.append("" + object); } public void println(Object object) throws IOException { print(object); bw.append("\n"); } public void close() throws IOException { bw.close(); } } public static void main(String[] args) { try { FastReader in = new FastReader(); FastWriter out = new FastWriter(); int testCases = in.nextInt(); while (testCases-- > 0) { int a = in.nextInt(); int b = in.nextInt(); int c = in.nextInt(); int timeByOne = 0; int timeByTwo = Math.abs(c-b); timeByOne += a-1; timeByTwo += c-1; if (timeByOne < timeByTwo) out.println(1); else if (timeByOne > timeByTwo) out.println(2); else out.println(3); } out.close(); } catch (Exception e) { return; } } }
Java
["3\n\n1 2 3\n\n3 1 2\n\n3 2 1"]
1 second
["1\n3\n2"]
NoteIn the first test case of the example, the first elevator is already on the floor of $$$1$$$.In the second test case of the example, when called, the elevators would move as follows: At the time of the call, the first elevator is on the floor of $$$3$$$, and the second one is on the floor of $$$1$$$, but is already going to another floor; in $$$1$$$ second after the call, the first elevator would be on the floor $$$2$$$, the second one would also reach the floor $$$2$$$ and now can go to the floor $$$1$$$; in $$$2$$$ seconds, any elevator would reach the floor $$$1$$$. In the third test case of the example, the first elevator will arrive in $$$2$$$ seconds, and the second in $$$1$$$.
Java 17
standard input
[ "math" ]
aca2346553f9e7b6e944ca2c74bb0b3d
The first line of the input contains the only $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, three integers each $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^8$$$, $$$b \ne c$$$) — floor numbers described in the statement.
800
Output $$$t$$$ numbers, each of which is the answer to the corresponding test case. As an answer, output: $$$1$$$, if it is better to call the first elevator; $$$2$$$, if it is better to call the second one; $$$3$$$, if it doesn't matter which elevator to call (both elevators will arrive in the same time).
standard output