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 | 323d52f04dc79792bf629107a3f37742 | 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=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int diff= Math.abs(b-c) + (c-1);
int tmp= a-1;
if(diff>tmp){
System.out.println(1);
}else if(diff<tmp){
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 | 34af75a2edc31ef81188057d2e8d7ef4 | 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 Codeforces {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for(int i = 0; i < n; i++){
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
int x = a - 1;
int y = Math.abs(b - c) + c - 1;
if(x < y){
System.out.println(1);
}else if(x > y){
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 | ae9f8ec9ab5e1c0e5184918b2677d540 | 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 sc = new Scanner(System.in);
int testCases = sc.nextInt();
while (testCases > 0){
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int fora = a-1;
int forb = Math.abs(c-b) + Math.abs(1-c);
if (fora > forb){
System.out.println(2);
}
else if (fora < forb){
System.out.println(1);
}
else {
System.out.println(3);
}
testCases--;
}
}
}
| 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 | 23cba963d083f78e7169876f3eab03f8 | 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.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.util.StringTokenizer;
public class abes {
public static void main(String[] args) {
FastScanner fs=new FastScanner();
PrintWriter out=new PrintWriter(System.out);
int T=fs.nextInt();
// int T=1;
for (int tt=0; tt<T; tt++) {
int a=fs.nextInt();
int b=fs.nextInt();
int c=fs.nextInt();
int temp =Math.abs(b-c)+c;
if(a<temp)System.out.println("1");
else if(a>temp)System.out.println("2");
else System.out.println("3");
}
out.close();
}
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;
}
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));
}
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]));
}
static void sort(int[] a) {
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);
}
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 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 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 | 7dee2982139d1be57c78143d980064d0 | 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;
/**
* @author Nikolay Chistykov
*/
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n = sc.nextInt();
while (n-- > 0) {
int[] ints = new int[3];
fillArray(ints);
int a = ints[0];
int b = ints[1];
int c = ints[2];
int s = 0;
if(b < c) {
s =Math.abs(c - b) + Math.abs(c - 1);
} else {
if(c != 1) {
s = Math.abs(b - c) + Math.abs(c-1);
} else {
s = Math.abs(b - c);
}
}
if((a-1) < s) {
System.out.println("1");
} else if((a-1) > s) {
System.out.println("2");
} else {
System.out.println("3");
}
}
}
private static void fillArray(int[] ints) {
for (int i = 0; i < ints.length; i++) {
ints[i] = sc.nextInt();
}
}
} | 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 | 1301bb42cb1ce52bd828c1b5a373454d | 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 KMPAlgorithm {
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 diff = a-1;
int absolute=Math.abs(c-b)+c-1;
if(absolute<diff){
System.out.println(2);
}
else if(absolute==diff){
System.out.println(3);
}
else{
System.out.println(1);
}
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 | cf833532bcd6fc0e514cdbb1ce4a3f25 | 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 Code2 {
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)){
System.out.println("1");
}else if ((a - 1) > (Math.abs(c - b)) + (c - 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 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 | 7a79eb5fabbed48ed78e650c834cbeaf | 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 pro1 {
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 a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
t--;
if(Math.abs(a-1) == Math.abs(c-1) + Math.abs(c-b)) System.out.println(3);
else if(Math.abs(a-1)<Math.abs(c-1) + Math.abs(c-b)) 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 | 74020dffca3cad1c905e1661b4e79268 | 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.*;
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 | 1ce69fc09e70859cf08ad00be22744da | 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 cf6 {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int t=sc.nextInt();
while(t>0){
long a=sc.nextLong();
long b=sc.nextLong();
long c=sc.nextLong();
long m=(a-1);
long d=Math.abs(b-c)+Math.abs(c-1);
if(m>d)
System.out.println(2);
else if(m<d)
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 | 54f0f1ea22b605d4732dec7580f361d4 | 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 cf2 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
int a,b,c;
for(int i=0;i<t;i++) {
a= sc.nextInt();
b= sc.nextInt();
c= sc.nextInt();
if(a==1){
System.out.println(1);
}
else if(c>b){
if(a <(2*c)-b){
System.out.println(1);
}else if(a>(2*c)-b){
System.out.println(2);
}else{
System.out.println(3);
}
} else if (c<b) {
if(a < b){
System.out.println(1);
}else if(a>b){
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 | da6aa29e0d4a3894513f4b5e72c46636 | 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 t=0;t<T;t++)
{
int a = sc.nextInt(), b= sc.nextInt(), 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 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 | 18bfe63ac0f4ea1c9ffa5ae4796c8b3c | 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 forces2 {
public static void main(String[] args)
{
Scanner sc =new Scanner(System.in);
int t = sc.nextInt();
while(t-->0)
{
// int n= sc.nextInt();
String s;
s = sc.next();
int i = Integer.parseInt(s);
int choice=0;
int y=0,z=0;
int num = 10;
while(choice!=3)
{
z = i%num + z;
i = i/num;
choice++;
}
int a=0;
int num2=10;
while(a!=3)
{
y = i%num2+y;
i = i/num2;
a++;
}
if(z==y)
{
System.out.println("Yes");
}
else
{
System.out.println("No");
}
}
}
}
*/
import java.util.*;
class forces2
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0)
{
// int n=sc.nextInt();
Long a=sc.nextLong();
Long b=sc.nextLong();
Long c=sc.nextLong();
Long x;
x=a-1l;
Long y;
y=c-1l;
Long z;
z=Math.abs(b-c);
Long w;
w=z+y;
if(x<w){
System.out.println("1");
}
else if(w<x){
System.out.println("2");
}
else
{
System.out.println("3");
}
// int n=sc.nextInt();
/* int index=0;
int n=sc.nextInt();
int []a=new int[n];
int sum=0;
int max=a[0];
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
if (max < a[i])
{
max = a[i];
index = i;
}
}
System.out.println(index+1);
*/
/* String s = sc.next();
char c='a';
char d='b';
int result=0;
int result2=0;
for(int i=0;i<s.length();i++)
{
if(s.charAt(i)==c)
result++;
if(s.charAt(i)==d)
result2++;
}
String s1="aabb";
String s2="bbaa";
if(s.equals(s1) || s.equals(s2))
{
System.out.println("Yes");
}
else if(result>=3 && result2>=2)
{
System.out.println("Yes");
}
else if(result>=2 && result2>=3)
{
System.out.println("Yes");
}
else if(result>=2 && result2==0)
{
System.out.println("Yes");
}
else if(result==0 && result2>=2)
{
System.out.println("Yes");
}
else
{
System.out.println("No");
}
*/
/* int res=0;
res=sum-a[0]-a[n-1];
int res2=0;
res2=a[0]+a[n-1];
int z;
z=res-res2;
System.out.println(Math.abs(z));}*/
// Long x =sc.nextLong();
//Long y=sc.nextLong();
// Long z = x/y;
// Long r =y/x;
/* if(x%y!=0 || y%x!=0)
{
System.out.println("0" + " " + "0");
}*/
/* if(y>=x && y%x==0)
{
System.out.println("1" + " " + r);
}
else{
System.out.println("0" + " " + "0");
}*/
/* int n =sc.nextInt();
int []a=new int[n];
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
Arrays.sort(a);
int x = a[n-1]-a[0];
System.out.println(x);
*/
/* String s = sc.next();
char c='a';
char d='b';
int result=0;
int result2=0;
for(int i=0;i<s.length();i++)
{
if(s.charAt(i)==c)
result++;
if(s.charAt(i)==d)
result2++;
}
if(result>=3 && result2>=2)
{
System.out.println("Yes");
}
else if(result>=2 && result2>=3)
{
System.out.println("Yes");
}
else if(result>=2 && result2==0)
{
System.out.println("Yes");
}
else if(result==0 && result2>=2)
{
System.out.println("Yes");
}
else
{
System.out.println("No");
}
*/
/* int n = sc.nextInt();
int a[] = new int[n];
int sum=0;
int choice=0;
int choice2=0;
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
for(int i=0;i<n;i++){
if(a[i]%2==0)
{
choice++;
}
if(a[i]%2!=0)
{
choice2++;
}
}
System.out.println(Math.min(choice,choice2));
*/
/* Long m = sc.nextLong();
Long y;
y=m;
int choice=0;
while(m!=0)
{
m=m/10;
choice++;
}
//System.out.println(choice);
choice--;
double x;
x=Math.pow(10, choice);
int val = (int) x;
Long res;
res=y-val;
System.out.println(res);
*/
/*int m=sc.nextInt();
int z=0;
int []a=new int[n];
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
z=z+a[i];
}
if(m>z)
{
System.out.println("0");
}
else
{
int x=z-m;
System.out.println(x);
}*/
/* int x = sc.nextInt();
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(x==3)
{
System.out.println("Yes");
}
else if(x==1 && (a==0 || a==1))
{
System.out.println("No");
}
else if(x==2 && (a==0 || a==1))
{
System.out.println("No");
}
else
{
System.out.println("Yes");
}
*/
}
}
} | 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 | 93643eee8528299dfac1dac8f65e9985 | 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 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();
int first= a-1;
int second= Math.abs(c-b ) + Math.abs(c-1);
if(first<second){
System.out.println(1);
}else if(second<first){
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 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 | 9edf5d09372089da530e652e204a7749 | 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 Temp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t > 0) {
t--;
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(b > c && b < a){
System.out.println("2");
}
else if(c > b && 2*c-b < a){
System.out.println("2");
}
else if(b > c && b > a)
{
System.out.println("1");
}
else if(c > b && 2*c-b > 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 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 | 286629093bf4980691c638fe2be34ad9 | 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.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
while (t-- > 0) {
StringTokenizer st = new StringTokenizer(br.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int c = Integer.parseInt(st.nextToken());
int d = (c - b) + c;
if (c < b) {
d = b;
}
if (a == d) {
System.out.println(3);
}
else if (a < d) {
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 | 103331f7862528f973648cea2dc14c10 | 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 Practise {
public static void main(String[] args) {
int t;
Scanner obj = new Scanner(System.in);
t = obj.nextInt();
while(t-->0){
int a = obj.nextInt();
int b = obj.nextInt();
int c = obj.nextInt();
int ele1 = Math.abs(a-1);
int ele2 = Math.abs(b-c)+Math.abs(c-1);
if(ele1>ele2){
System.out.println(2);
}
else if(ele2>ele1){
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 | d340eb267911326e02a9dbddcad11f29 | 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.IOException;
public class CF1729 {
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 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 scan = new Reader();
int t = scan.nextInt();
int a, b, c;
for (int i = 1; i <= t; i++) {
a = scan.nextInt();
b = scan.nextInt();
c = scan.nextInt();
if( (a-1) > (Math.abs(b-c) + c - 1)){
System.out.println(2);
}
else if( (a-1) < (Math.abs(b-c) + c - 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 | 150aff7d435e86f5875ef5a5fc2efca0 | 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 CF1729 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
int a, b, c;
for (int i = 1; i <= t; i++) {
a = scan.nextInt();
b = scan.nextInt();
c = scan.nextInt();
if( (a-1) > (Math.abs(b-c) + c - 1)){
System.out.println(2);
}
else if( (a-1) < (Math.abs(b-c) + c - 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 | 625a2625c9fccdde4d030a8d9ab9bfb6 | 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.*;
public class Solution {
static boolean check = false;
//
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(reader.readLine());
for (int j = 0; j < n; j++) {
String[] data = reader.readLine().split(" ", 1000);
int a = Integer.parseInt(data[0]);
int b = Integer.parseInt(data[1]);
int c = Integer.parseInt(data[2]);
int summaB = 0;
int summaA = 0;
summaA+=a;
if (c>b){
c = c-b;
summaB+=b+(c)*2;
}
else {
summaB+=b;
}
if (summaB>summaA){
System.out.println(1);
} else if (summaB<summaA) {
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 | d7ab034749f90410f305d39b68cd6231 | 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 int twoElevators(int a, int b, int c) {
int elevatorTime2 = Math.abs(c - b) + c;
if (elevatorTime2 > a) {
return 1;
}
else if (elevatorTime2 < a) {
return 2;
}
return 3;
}
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
int repeat = console.nextInt();
for (int i = 0; i < repeat; i++) {
int a = console.nextInt();
int b = console.nextInt();
int c = console.nextInt();
System.out.println(twoElevators(a, b, c));
}
}
} | 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 | e468787f3b4f090f702ae0a1a0f81879 | 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 Solve {
static Scanner sc = new Scanner(System.in);
private static void solve() {
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
a--;
int a1 = Math.abs(c - b) + (c - 1);
if (a < a1) {
System.out.println(1);
}
if (a > a1) {
System.out.println(2);
}
if (a == a1) {
System.out.println(3);
}
}
public static void main(String[] args) {
int tt = sc.nextInt();
while (tt-- > 0) {
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 | a1779bec49cf8acda17a3fd4e448329f | 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 num=input.nextInt();
int i;
for(i=1;i<=num;i++){
int a=input.nextInt();
int b=input.nextInt();
int c=input.nextInt();
int first=a-1;
int second=Math.abs(b-c)+c-1;
if(second>first){
System.out.println(1);
}
if(second<first){
System.out.println(2);
}
if(first==second){
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 | ee86ec8b197f950ac02e748cf5008ff7 | 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 x = Integer.parseInt(input.next());
for (int i = 0; i < x; i++) {
int a = input.nextInt();
int b = input.nextInt();
int c = input.nextInt();
jud(a,b,c);
}
}
public static void jud(int a,int b,int c){
int elevator2 = Math.abs(c-b)+Math.abs(c-1);
int elevator1 = Math.abs(a-1);
if (elevator1<elevator2){
System.out.println(1);
} else if (elevator1>elevator2) {
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 | bdb3093790726dd228a6f99e67c40e0d | 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 x = Integer.parseInt(input.next());
for (int i = 0; i < x; i++) {
int a = input.nextInt();
int b = input.nextInt();
int c = input.nextInt();
jud(a,b,c);
}
}
public static void jud(int a,int b,int c){
int elevator2 = Math.abs(c-b)+Math.abs(c-1);
int elevator1 = Math.abs(a-1);
if (elevator1<elevator2){
System.out.println(1);
} else if (elevator1>elevator2) {
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 | e32b435e3d1562d2d2ea35308416ede5 | 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.Math;
import java.util.*;
public class lift
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t;
t = sc.nextInt();
while(t>0){
int a,b,c;
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
int aa = a-1;
int bb = Math.abs(c-b)+c-1;
if (aa>bb){
System.out.println(2);
}
else if(bb>aa){
System.out.println(1);
}
else{
System.out.println(3);
}
t--;
}
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 | 2fd42d18fce7e58abcbcc19c6c3dda29 | 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 Java_classes;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Two_Elevators {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int test_case = Integer.parseInt(in.readLine());
for(int i = 0; i<test_case; i++) {
String[] lines = in.readLine().split(" ");
int a = Integer.parseInt(lines[0]);
int b = Integer.parseInt(lines[1]);
int c = Integer.parseInt(lines[2]);
int sec1 = a-1;
int sec2 = 0;
if(c>b) {
sec2 = (c-b)+(c-1);
}
else if(c<b) {
sec2 = b-1;
}
else if(b==1) {
sec2 = (c-b)+(c-1);
}
if(sec1<sec2) {
System.out.println(1);
}
else if(sec1>sec2) {
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 | 5625fc48a09bbd5f0f8f0c63145b6982 | 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.Math;
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=sc.nextInt(), b=sc.nextInt(), c=sc.nextInt();
int t1=Math.abs(a-1);
int t2=Math.abs(b-c)+Math.abs(c-1);
if (c==1)
{
int x=a-1;
int y=b-1;
if(x>y)
System.out.println("2");
else if(x<y)
System.out.println("1");
else
System.out.println("3");
}
else{
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 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 | d97ac38e8e5a2b1f3013150f95f21f18 | 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 m=a-1;
int d=Math.abs(b-c)+Math.abs(c-1);
if(d>m) System.out.println(1);
else if(d<m) 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 | 2409625c0b600b50ac34ee94661319d3 | 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 {
static int compute(int a, int b, int c) {
int d1 = Math.abs(a-1);
int d2 = Math.abs(b-c) + Math.abs(c-1);
if (d1 < d2) {
return 1;
} else if (d1 > d2) {
return 2;
} else {
return 3;
}
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
for (int i = 0; i < t; i++) {
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
System.out.println(compute(a, b, c));
}
}
} | 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 | 1d4bcf92e53c5243fa8d2ea8cfa80eaf | 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 inp = new Scanner(System.in);
int t = inp.nextInt();
while (t-- > 0) {
int a = inp.nextInt(), b = inp.nextInt(), c = inp.nextInt();
int timea = a - 1;
int timeb = Math.abs(c - b) + c - 1;
if (timea < timeb)
System.out.println(1);
else if (timea > timeb)
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 | 5dbb5efedf1d8813a7fbbc2c8fb00825 | 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 ContestX {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
var t = sc.nextInt();
for (var ti = 0; ti < t; ti++) {
var a = sc.nextInt();
var b = sc.nextInt();
var c = sc.nextInt();
var r = doStuff(a, b, c);
System.out.println(r);
}
}
}
private static int doStuff(int a, int b, int c) {
var acost = a - 1;
var bcost = c > b
? (c - b) + (c - 1)
: (b - 1);
if (acost < bcost) {
return 1;
}
if (acost > bcost) {
return 2;
}
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 | 035d3e7523edce12af6922343d744496 | 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 Codechef
{
public static class Pair {
int x;
int y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
}
private static final int modulo = 1000000007;
public static Scanner scan = new Scanner(System.in);
public static void main (String[] args) throws java.lang.Exception {
int testCases = scan.nextInt();
for (int vedant = 0; vedant < testCases; vedant++) {
solve();
}
}
private static void solve() {
// ******************** S O L V E M E T H O D *****************
// ************* M A I N L O G I C G O E S H E R E **********
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
if (a == 1) {
System.out.println(1);
return;
}
a--;
int secondLift = Math.abs(c - b);
secondLift += Math.abs(c - 1);
// System.out.println("a = " + a);
// System.out.println("secondLift = " + secondLift);
if (a < secondLift) {
System.out.println(1);
} else if (secondLift < a) {
System.out.println(2);
} else {
System.out.println(3);
}
}
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;
}
private static long getFrequency(List<Long> array, long target) {
long count = 0;
for (long element : array) {
if (element == target) {
count++;
}
}
return count;
}
private static void printYES() {
System.out.println("YES");
}
private static void printNO() {
System.out.println("NO");
}
private static int[] readIntArray(int size) {
int[] arr = new int[size];
for (int i = 0; i < size; i++) {
arr[i] = scan.nextInt();
}
return arr;
}
private static long[] readLongArray(int size) {
long[] arr = new long[size];
for (int i = 0; i < size; i++) {
arr[i] = scan.nextLong();
}
return arr;
}
private static boolean isVowel(char charAt) {
charAt = Character.toLowerCase(charAt);
if (charAt == 'a' ||
charAt == 'e' ||
charAt == 'i' ||
charAt == 'o' ||
charAt == 'u') {
return true;
} else {
return false;
}
}
private static long getMaximumFromList(List<Long> arr) {
long max = Long.MIN_VALUE;
for (int i = 0; i < arr.size(); i++) {
max = Math.max(max, arr.get(i));
}
return max;
}
public static int binarySearch(int[] arr, int target) {
int starting = 0;
int ending = arr.length - 1;
while (starting < ending) {
int mid = starting + (ending - starting) / 2;
if (arr[mid] == target) {
return mid;
}
if (arr[mid] > target) {
ending = mid - 1;
} else {
starting = mid + 1;
}
}
return -1;
}
public static int binarySearch(long[] arr, long target) {
int starting = 0;
int ending = arr.length - 1;
while (starting < ending) {
int mid = starting + (ending - starting) / 2;
if (arr[mid] == target) {
return mid;
}
if (arr[mid] > target) {
ending = mid - 1;
} else {
starting = mid + 1;
}
}
return -1;
}
public static int gcd(int a, int b) {
// Everything divides 0
if (a == 0)
return b;
if (b == 0)
return a;
// base case
if (a == b)
return a;
// a is greater
if (a > b)
return gcd(a-b, b);
return gcd(a, b-a);
}
public static long gcd(long a, long b) {
// Everything divides 0
if (a == 0)
return b;
if (b == 0)
return a;
// base case
if (a == b)
return a;
// a is greater
if (a > b)
return gcd(a-b, b);
return gcd(a, b-a);
}
} | 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 | 2db2b6aa03143804e080953540c946d9 | 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 n = input.nextInt();
int a, b, c, razn;
for (int i = 0; i < n; i++){
a = input.nextInt();
b = input.nextInt();
c = input.nextInt();
if(c < b) razn = b;
else razn = 2 * c - b;
if(a < razn){
System.out.println(1);
}else if(a == razn){
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 | 895ace495579611b01e00afd07ff7db2 | 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 g=1;
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int x=Math.abs(a-g);
int y=Math.abs((c-b))+Math.abs((c-g));
if(y==x)
System.out.println("3");
else if(y>x)
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 | 550e4c58301261743d818a4147b29519 | 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.*;
/*
Set<String> hash_Set = new HashSet<String>();
// Demonstrating Set using HashSet
// Declaring object of type String
Set<String> hash_Set = new HashSet<String>();
// Adding elements to the Set
// using add() method
hash_Set.add("Geeks");
hash_Set.add("For");
hash_Set.add("Geeks");
hash_Set.add("Example");
hash_Set.add("Set");
// Printing elements of HashSet object
System.out.println(hash_Set);
*/
public class Main {
static BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
static StringTokenizer tok;
public static void check() throws IOException {
if (tok == null || !tok.hasMoreTokens())
tok = new StringTokenizer(read.readLine());
}
public static int nextInt() throws IOException {
return Integer.parseInt(nextString());
}
public static long nextLong() throws IOException {
return Long.parseLong(nextString());
}
public static double nextDouble() throws IOException {
return Double.parseDouble(nextString());
}
public static String nextString() throws IOException {
check();
return tok.nextToken();
}
public static void println(Object o) {
out.println(o);
out.flush();
}
public static int[] nextArray(int n) throws IOException {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
static int findLCM(int x, int y) {
// LCM(a, b) = (a x b) / GCD(a, b)
return (x * y) / findGCD(x, y);
}
static int findGCD(int x, int y) {
int r = 0, a, b;
a = (x > y) ? x : y;
b = (x < y) ? x : y;
r = b;
while (a % b != 0) {
r = a % b;
a = b;
b = r;
}
return r;
}/*
boolean [] primes = new boolean[n+1];
for(int i =0; i<primes.length; i++){
primes[i] =true;
}
for(int i =2; i*i< primes.length; i++){
if(primes[i] == true){
for(int j = i*i; j<=n; j+=i){
primes[j] =false;
}
}
}for(int i = 2; i<primes.length; i++){
if(primes[i])
System.out.println(i);
}
*/
public static void main(String[] args) throws IOException {
int t = nextInt();
int a, b, c = 0;
for (int i = 0; i < t; i++) {
a = nextInt();
b = nextInt();
c = nextInt();
int sumA = Math.abs(a-1);
int sumB = Math.abs(b-c);
sumB+= Math.abs(c-1);
if(sumA <sumB)
System.out.println(1);
else if(sumA > sumB)
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 | a0be5e601e8e2a82b8407a5cd60ca43e | 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 scan = new Scanner(System.in);
int t = scan.nextInt();
int a, b, c, l1 = 0;
int l2 = 0;
for(int i = 0; i < t; i++){
a = scan.nextInt();
b = scan.nextInt();
c = scan.nextInt();
l1 = a; l2 = Math.abs(c-b) + c;
if(l1 < l2) {
System.out.println(1);
}else if (l1 > l2){
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 | b7237d4a0ff0ef534b401799fc3ed44a | 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) {
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))){
System.out.println(1);;
}else if((a-1) > (Math.abs((c - b)) + (c - 1))){
System.out.println(2);
}else{
System.out.println(3);
}
t--;
}
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 | ab78b9e02e7a753cfe368abb721feaa3 | 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 {
private static final int INT_MAX = 999999999;
/*public static int power(int x,int n) {
if(n==0)
return 1;
return x*power(x,n-1);
}*/
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int test=0;test<t;test++) {
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int one=a;
int two;
if(b>c)
two=b;
else
two=2*c-b;
if(one<two)
System.out.println(1);
else if(one==two)
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 | de2ed6efa94d7e58cca6bc319b8c102d | 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) {
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");
}
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 | e410f461df80a030b7a638f6e121cb44 | 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.Scanner;
public class file
{
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 d1=Math.abs(a-1);
int d2=Math.abs(b-c)+Math.abs(c-1);
if(d1<d2)
System.out.println("1");
else if(d2<d1)
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 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 | 172d9e92ac5e3aaa08c8fc2f7078edc3 | 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 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(a==1){
System.out.println("1");
}
else{
long ans1=(long)Math.abs(a-1);
long ans2=(long)Math.abs(b-c)+Math.abs(c-1);
if(ans1==ans2){
System.out.println("3");
}
else if(ans1<ans2){
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 | 659b1a9400b2956ce1db89d865ca093f | 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 n = sc.nextInt();
for(int m = 1; m <= n; m++){
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int diffOne = a - 1;
int diffTwo = 0;
if(b < c) diffTwo = (c-b) + (c-1);
else diffTwo = b - 1;
if(diffOne < diffTwo) System.out.println("1");
else if(diffOne > diffTwo) System.out.println("2");
else System.out.println("3");
}
// }
// int l = sc.nextInt();
// int[] ans = new int[3];
// String ar1[] = new String[l];
// HashMap<String,String> map1 = new HashMap<>();
// String ar2[] = new String[l];
// HashMap<String,String> map2 = new HashMap<>();
// String ar3[] = new String[l];
// HashMap<String,String> map3 = new HashMap<>();
// for(int j = 0; j < l; j++){
// ar1[j] = sc.next();
// map1.put(ar1[j],"");
// }
// for(int j = 0; j < l; j++){
// ar2[j] = sc.next();
// map2.put(ar2[j],"");
// }
// for(int j = 0; j < l; j++){
// ar3[j] = sc.next();
// map3.put(ar3[j],"");
// }
// for(int i = 0; i < ar1.length; i++){
// String k = ar1[i];
// if(map2.containsKey(k)){
// if(!map3.containsKey(k)){
// ans[0] += 1;
// }
// }else if(map3.containsKey(k)){
// ans[0] += 1;
// }else{
// ans[0] += 3;
// }
// }
// for(int i = 0; i < ar2.length; i++){
// String k = ar2[i];
// if(map1.containsKey(k)){
// if(!map3.containsKey(k)){
// ans[1] += 1;
// }
// }else if(map3.containsKey(k)){
// ans[1] += 1;
// }else{
// ans[1] += 3;
// }
// }
// for(int i = 0; i < ar3.length; i++){
// String k = ar3[i];
// if(map1.containsKey(k)){
// if(!map2.containsKey(k)){
// ans[2] += 1;
// }
// }else if(map2.containsKey(k)){
// ans[2] += 1;
// }else{
// ans[2] += 3;
// }
// }
// System.out.println(ans[0] + " " + ans[1] + " " + ans[2]);
// }
// String b = sc.next();
// boolean breaked = false;
// for(int j = 0; j < l; j++){
// if(a.charAt(j) == 'R'){
// if(b.charAt(j) != 'R'){
// System.out.println("NO");
// breaked = true;
// break;
// }
// }else if(b.charAt(j) == 'R'){
// System.out.println("NO");
// breaked = true;
// break;
// }
// }
// if(!breaked) System.out.println("YES");
// if(l != 5){
// System.out.println("NO");
// continue;
// }
// int[] arr = new int[256];
// for(int k = 0; k < s.length(); k++){
// arr[s.charAt(k)] = 1;
// }
// boolean valid = true;
// String str = "Timur";
// for(int k = 0; k < str.length(); k++){
// if(arr[str.charAt(k)] != 1){
// valid = false;
// break;
// }
// }
// if(valid) System.out.println("YES");
// else System.out.println("No");
// }
}
} | 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 | 776f6c0d0975ee6af9c8b34c3704e7b2 | 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 p2{
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();
int f = Math.abs(b-c)+Math.abs(c-1)+1;
if(f>a) {
System.out.println("1");
}
else if(f<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 | 0b3caef3a0a654dfb5708ca0310f7846 | 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 mS = new Scanner(System.in);
long a;
long b;
long c;
long dis;
int rep = mS.nextInt();
for(int i = 0; i < rep; ++i) {
a = mS.nextLong();
b = mS.nextLong();
c = mS.nextLong();
dis = (b > c) ? (c-1) + (b-c) : (c-1) + (c-b);
if(a-1 > dis) {
System.out.println(2);
}
else if (a-1 == dis) {
System.out.println(3);
}
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 | b3f2241c78f8550cdadb19ef172fd6bc | 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 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 x = a-1;
int y = Math.max(b,c)-Math.min(b,c);
int z = 0;
if(b<c){
z = Math.max(b,c)-1+y;
}else{
z = Math.max(b,c)-1;
}
if(x>z){
System.out.println(2);
}else if(z>x){
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 | abddec5a0e6776b7966515b2abe7f760 | 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 | /**
*
* @author AshwinA
*/
import java.util.*;
import java.lang.*;
import java.io.*;
public class CP_IMP_2{
public static void main (String[] args) throws java.lang.Exception{
Reader in = new Reader();
Writer out = new Writer();
int t = in.nextInt();
while(t-->0){
int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
if(b > c){
// out.println(Math.min(a-1, c-b+c-1));
if(a-1 < b-1){
out.println(1);
}else if(a-1 == b-1){
out.println(3);
}else{
out.println(2);
}
}else{
// out.println(Math.min(a-1, b-c + Math.abs(c-1) ));
if(a-1 < c-b + c-1){
out.println(1);
}else if(a-1 == c-b + c-1){
out.println(3);
}else{
out.println(2);
}
}
}
out.close();
}
static class Reader {
private final BufferedReader br;
private StringTokenizer st;
public Reader() {
this.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 string = "";
try {
string = br.readLine().trim();
} catch (IOException e) {
e.printStackTrace();
}
return string;
}
}
static class Writer {
private final BufferedWriter bw;
public Writer() {
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 {
this.print(object);
bw.append("\n");
}
public void close() throws IOException {
bw.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 | dd8ad33dbbb1c9bfeb328e3d2b0e5fcc | 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 CF1729A {
// For fast input output
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
try {
br = new BufferedReader(
new FileReader("input.txt"));
PrintStream out = new PrintStream(new FileOutputStream("output.txt"));
System.setOut(out);
} catch (Exception e) {
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());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
// end of fast i/o code
public static boolean isPalindrome(String str) {
int i = 0;
int j = str.length() - 1;
int flag = 0;
while (i <= j) {
if (str.charAt(i) != str.charAt(j)) {
flag = 1;
break;
}
i++;
j--;
}
return flag == 1 ? false : true;
}
public static int gcd(int a, int b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
class Pair {
int x1;
int x2;
public Pair(int x1, int x2) {
this.x1 = x1;
this.x2 = x2;
}
}
static void solve() {
}
public static void main(String[] args) {
FastReader fs = new FastReader();
PrintWriter out = new PrintWriter(System.out);
// solve();
int t=fs.nextInt();
while(t-->0){
long a=fs.nextInt();
long b =fs.nextInt();
long c=fs.nextInt();
long temp=Math.abs(b-c)+c-1;
if(a==1 || Math.abs(a-1)<temp)
out.println(1);
else if(Math.abs(a-1)>temp)
out.println(2);
else
out.println(3);
}
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 | 637ae65198367da44b2c69ef7aa08483 | 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 Round817_div4;
import java.util.Scanner;
public class test2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
while(n-->0){
// int f = 0;
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(a == 1){
System.out.println(1);
// break;
}else{
int af = a-1;
int x = Math.abs(c-b)+Math.abs(c-1);
if(af < x) {
System.out.println(1);
// break;
}else if(af > x){
System.out.println(2);
// break;
}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 | c4361f6f016aa5193519ed09e3fcd34f | 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 ide;
import java.util.*;
import java.lang.*;
public class codechef {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int t=1;
t=sc.nextInt();
while(t-->0){
// Scanner sc = new Scanner(System.in);
int a= sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int p=Math.abs(a-1);
int q=Math.abs(b-c)+Math.abs(c-1);
if(p<q) System.out.println(1);
else if(p>q) 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 | 2df43de33bed48e20006a1486a0c644e | 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.PrintWriter;
import java.util.Scanner;
public class elevator {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int testCases = scnr.nextInt();
for (int i = 0; i < testCases; i++) {
int el1 = scnr.nextInt();
int el2 = scnr.nextInt();
int el3 = scnr.nextInt();
int t1 = el1-1, t2 = 0, max = 0;
if(el3 < el2) {
t2 = el2-1;
}
else if(el3 > el2) {
t2 = el3-1 + el3 - el2;
}
if(t1 > t2) {
max = 2;
}
else if(t1 < t2) {
max = 1;
}
else {
max = 3;
}
out.println(max);
}
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 | 840419930498661f5e08476bfe29f1d4 | 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.nio.charset.StandardCharsets;
import java.util.Scanner;
public class CF1729A {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in, StandardCharsets.UTF_8);
int t = scanner.nextInt();
for (int i = 0; i < t; i++) {
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
System.out.println(solve(a, b, c));
}
}
private static String solve(int a, int b, int c) {
int t1 = a - 1;
int t2 = Math.abs(c - b) + c - 1;
if (t1 == t2) {
return "3";
} else if (t1 < t2) {
return "1";
} else {
return "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 | 8b441d36dee8a785f8fcdee45e6b8bf3 | 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);
int t = Integer.parseInt(sc.nextLine());
while (t>0){
long a = sc.nextInt();
long b = sc.nextInt();
long c = sc.nextInt();
long firstElevator = a-1;
long secondElevator = 0;
if (c>b){
secondElevator = (c-b) + (c-1);
}else {
secondElevator = b-1;
}
if (firstElevator==secondElevator) System.out.println(3);
else if (firstElevator>secondElevator) System.out.println(2);
else System.out.println(1);
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 | 4733463182da1e9d3d34e20efaaee00f | 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.*;
/**
*
* @author eslam
*/
public class Solution {
// Beginning of the solution
static Kattio input = new Kattio();
static BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
static ArrayList<ArrayList<Integer>> powerSet = new ArrayList<>();
static ArrayList<LinkedList<Integer>> allprem = new ArrayList<>();
static ArrayList<LinkedList<String>> allprems = new ArrayList<>();
static ArrayList<Long> luc = new ArrayList<>();
static long mod = (long) (Math.pow(10, 9) + 7);
static int grid[][] = {{0, 0, 1, -1, 1, 1, -1, -1}, {1, -1, 0, 0, 1, -1, 1, -1}};
static int dp[][];
static double cmp = 0.000000001;
public static void main(String[] args) throws IOException {
// Kattio input = new Kattio("input");
// BufferedWriter log = new BufferedWriter(new FileWriter("output.txt"));
int test = input.nextInt();
loop:
for (int o = 1; o <= test; o++) {
int a = input.nextInt();
int b = input.nextInt();
int c = input.nextInt();
int ans1 = a - 1;
int ans2 = Math.abs(b - c) + (c - 1);
if (ans1 == ans2) {
log.write("3\n");
} else if (ans1 < ans2) {
log.write("1\n");
} else {
log.write("2\n");
}
}
log.flush();
}
static Comparator<tri> cmpTri() {
Comparator<tri> c = new Comparator<tri>() {
@Override
public int compare(tri o1, tri o2) {
if (o1.x > o2.x) {
return 1;
} else if (o1.x < o2.x) {
return -1;
} else {
if (o1.y > o2.y) {
return 1;
} else if (o1.y < o2.y) {
return -1;
} else {
if (o1.z > o2.z) {
return 1;
} else if (o1.z < o2.z) {
return -1;
} else {
return 0;
}
}
}
}
};
return c;
}
static Comparator<pair> cmpPair() {
Comparator<pair> c = new Comparator<pair>() {
@Override
public int compare(pair o1, pair o2) {
if (o1.x > o2.x) {
return 1;
} else if (o1.x < o2.x) {
return -1;
} else {
if (o1.y > o2.y) {
return 1;
} else if (o1.y < o2.y) {
return -1;
} else {
return 0;
}
}
}
};
return c;
}
static class rec {
long x1;
long x2;
long y1;
long y2;
public rec(long x1, long y1, long x2, long y2) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}
public long getArea() {
return (x2 - x1) * (y2 - y1);
}
}
static int sumOfRange(int x1, int y1, int x2, int y2, int e, int a[][][]) {
return (a[e][x2][y2] - a[e][x1 - 1][y2] - a[e][x2][y1 - 1]) + a[e][x1 - 1][y1 - 1];
}
public static int[][] bfs(int i, int j, String w[]) {
Queue<pair> q = new ArrayDeque<>();
q.add(new pair(i, j));
int dis[][] = new int[w.length][w[0].length()];
for (int k = 0; k < w.length; k++) {
Arrays.fill(dis[k], -1);
}
dis[i][j] = 0;
while (!q.isEmpty()) {
pair p = q.poll();
int cost = dis[p.x][p.y];
for (int k = 0; k < 4; k++) {
int nx = p.x + grid[0][k];
int ny = p.y + grid[1][k];
if (isValid(nx, ny, w.length, w[0].length())) {
if (dis[nx][ny] == -1 && w[nx].charAt(ny) == '.') {
q.add(new pair(nx, ny));
dis[nx][ny] = cost + 1;
}
}
}
}
return dis;
}
public static void dfs(int node, ArrayList<Integer> a[], boolean vi[]) {
vi[node] = true;
for (Integer ch : a[node]) {
if (!vi[ch]) {
dfs(ch, a, vi);
}
}
}
public static void graphRepresintion(ArrayList<Integer>[] a, int q) throws IOException {
for (int i = 0; i < a.length; i++) {
a[i] = new ArrayList<>();
}
while (q-- > 0) {
int x = input.nextInt();
int y = input.nextInt();
a[x].add(y);
a[y].add(x);
}
}
public static boolean isValid(int i, int j, int n, int m) {
return (i > -1 && i < n) && (j > -1 && j < m);
}
// present in the left and right indices
public static int[] swap(int data[], int left, int right) {
// Swap the data
int temp = data[left];
data[left] = data[right];
data[right] = temp;
// Return the updated array
return data;
}
// Function to reverse the sub-array
// starting from left to the right
// both inclusive
public static int[] reverse(int data[], int left, int right) {
// Reverse the sub-array
while (left < right) {
int temp = data[left];
data[left++] = data[right];
data[right--] = temp;
}
// Return the updated array
return data;
}
// Function to find the next permutation
// of the given integer array
public static boolean findNextPermutation(int data[]) {
// If the given dataset is empty
// or contains only one element
// next_permutation is not possible
if (data.length <= 1) {
return false;
}
int last = data.length - 2;
// find the longest non-increasing suffix
// and find the pivot
while (last >= 0) {
if (data[last] < data[last + 1]) {
break;
}
last--;
}
// If there is no increasing pair
// there is no higher order permutation
if (last < 0) {
return false;
}
int nextGreater = data.length - 1;
// Find the rightmost successor to the pivot
for (int i = data.length - 1; i > last; i--) {
if (data[i] > data[last]) {
nextGreater = i;
break;
}
}
// Swap the successor and the pivot
data = swap(data, nextGreater, last);
// Reverse the suffix
data = reverse(data, last + 1, data.length - 1);
// Return true as the next_permutation is done
return true;
}
public static pair[] dijkstra(int node, ArrayList<pair> a[]) {
PriorityQueue<tri> q = new PriorityQueue<>(new Comparator<tri>() {
@Override
public int compare(tri o1, tri o2) {
if (o1.y > o2.y) {
return 1;
} else if (o1.y < o2.y) {
return -1;
} else {
return 0;
}
}
});
q.add(new tri(node, 0, -1));
pair distance[] = new pair[a.length];
while (!q.isEmpty()) {
tri p = q.poll();
int cost = p.y;
if (distance[p.x] != null) {
continue;
}
distance[p.x] = new pair(p.z, cost);
ArrayList<pair> nodes = a[p.x];
for (pair node1 : nodes) {
if (distance[node1.x] == null) {
tri pa = new tri(node1.x, cost + node1.y, p.x);
q.add(pa);
}
}
}
return distance;
}
public static String revs(String w) {
String ans = "";
for (int i = w.length() - 1; i > -1; i--) {
ans += w.charAt(i);
}
return ans;
}
public static boolean isPalindrome(String w) {
for (int i = 0; i < w.length() / 2; i++) {
if (w.charAt(i) != w.charAt(w.length() - i - 1)) {
return false;
}
}
return true;
}
public static void getPowerSet(Queue<Integer> a) {
int n = a.poll();
if (!a.isEmpty()) {
getPowerSet(a);
}
int s = powerSet.size();
for (int i = 0; i < s; i++) {
ArrayList<Integer> ne = new ArrayList<>();
ne.add(n);
for (int j = 0; j < powerSet.get(i).size(); j++) {
ne.add(powerSet.get(i).get(j));
}
powerSet.add(ne);
}
ArrayList<Integer> p = new ArrayList<>();
p.add(n);
powerSet.add(p);
}
public static int getlo(int va) {
int v = 1;
while (v <= va) {
if ((va&v) != 0) {
return v;
}
v <<= 1;
}
return 0;
}
static long fast_pow(long a, long p, long mod) {
long res = 1;
while (p > 0) {
if (p % 2 == 0) {
a = (a * a) % mod;
p /= 2;
} else {
res = (res * a) % mod;
p--;
}
}
return res;
}
public static int countPrimeInRange(int n, boolean isPrime[]) {
int cnt = 0;
Arrays.fill(isPrime, true);
for (int i = 2; i * i <= n; i++) {
if (isPrime[i]) {
for (int j = i * 2; j <= n; j += i) {
isPrime[j] = false;
}
}
}
for (int i = 2; i <= n; i++) {
if (isPrime[i]) {
cnt++;
}
}
return cnt;
}
public static void create(long num) {
luc.add(num);
if (num > power(10, 9)) {
return;
}
create(num * 10 + 4);
create(num * 10 + 7);
}
public static long ceil(long a, long b) {
return (a + b - 1) / b;
}
public static long round(long a, long b) {
if (a < 0) {
return (a - b / 2) / b;
}
return (a + b / 2) / b;
}
public static void allPremutationsst(LinkedList<String> l, boolean visited[], ArrayList<String> st) {
if (l.size() == st.size()) {
allprems.add(l);
}
for (int i = 0; i < st.size(); i++) {
if (!visited[i]) {
visited[i] = true;
LinkedList<String> nl = new LinkedList<>();
for (String x : l) {
nl.add(x);
}
nl.add(st.get(i));
allPremutationsst(nl, visited, st);
visited[i] = false;
}
}
}
public static void allPremutations(LinkedList<Integer> l, boolean visited[], int a[]) {
if (l.size() == a.length) {
allprem.add(l);
}
for (int i = 0; i < a.length; i++) {
if (!visited[i]) {
visited[i] = true;
LinkedList<Integer> nl = new LinkedList<>();
for (Integer x : l) {
nl.add(x);
}
nl.add(a[i]);
allPremutations(nl, visited, a);
visited[i] = false;
}
}
}
public static int binarySearch(long[] a, long value) {
int l = 0;
int r = a.length - 1;
while (l <= r) {
int m = (l + r) / 2;
if (a[m] == value) {
return m;
} else if (a[m] > value) {
r = m - 1;
} else {
l = m + 1;
}
}
return -1;
}
public static void reverse(int l, int r, char ch[]) {
for (int i = 0; i < r / 2; i++) {
char c = ch[i];
ch[i] = ch[r - i - 1];
ch[r - i - 1] = c;
}
}
public static int logK(long v, long k) {
int ans = 0;
while (v > 1) {
ans++;
v /= k;
}
return ans;
}
public static long power(long a, long n) {
if (n == 1) {
return a;
}
long pow = power(a, n / 2);
pow *= pow;
if (n % 2 != 0) {
pow *= a;
}
return pow;
}
public static long get(long max, long x) {
if (x == 1) {
return max;
}
int cnt = 0;
while (max > 0) {
cnt++;
max /= x;
}
return cnt;
}
public static int numOF0(long v) {
long x = 1;
int cnt = 0;
while (x <= v) {
if ((x & v) == 0) {
cnt++;
}
x <<= 1;
}
return cnt;
}
public static int log2(double n) {
int cnt = 0;
while (n > 1) {
n /= 2;
cnt++;
}
return cnt;
}
public static int[] bfs(int node, ArrayList<Integer> a[]) {
Queue<Integer> q = new LinkedList<>();
q.add(node);
int distances[] = new int[a.length];
Arrays.fill(distances, -1);
distances[node] = 0;
while (!q.isEmpty()) {
int parent = q.poll();
ArrayList<Integer> nodes = a[parent];
int cost = distances[parent];
for (Integer node1 : nodes) {
if (distances[node1] == -1) {
q.add(node1);
distances[node1] = cost + 1;
}
}
}
return distances;
}
public static ArrayList<Integer> primeFactors(int n) {
ArrayList<Integer> a = new ArrayList<>();
while (n % 2 == 0) {
a.add(2);
n /= 2;
}
for (int i = 3; i <= Math.sqrt(n); i += 2) {
while (n % i == 0) {
a.add(i);
n /= i;
}
if (n < i) {
break;
}
}
if (n > 2) {
a.add(n);
}
return a;
}
public static ArrayList<Integer> printPrimeFactoriztion(int n) {
ArrayList<Integer> a = new ArrayList<>();
for (int i = 1; i < Math.sqrt(n) + 1; i++) {
if (n % i == 0) {
if (isPrime(i)) {
a.add(i);
n /= i;
i = 0;
} else if (isPrime(n / i)) {
a.add(n / i);
n = i;
i = 0;
}
}
}
return a;
}
// end of solution
public static BigInteger f(long n) {
if (n <= 1) {
return BigInteger.ONE;
}
long t = n - 1;
BigInteger b = new BigInteger(t + "");
BigInteger ans = new BigInteger(n + "");
while (t > 1) {
ans = ans.multiply(b);
b = b.subtract(BigInteger.ONE);
t--;
}
return ans;
}
public static long factorial(long n) {
if (n <= 1) {
return 1;
}
long t = n - 1;
while (t > 1) {
n = mod((mod(n, mod) * mod(t, mod)), mod);
t--;
}
return n;
}
public static long rev(long n) {
long t = n;
long ans = 0;
while (t > 0) {
ans = ans * 10 + t % 10;
t /= 10;
}
return ans;
}
public static boolean isPalindrome(int n) {
int t = n;
int ans = 0;
while (t > 0) {
ans = ans * 10 + t % 10;
t /= 10;
}
return ans == n;
}
static class tri {
int x, y, z;
public tri(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
@Override
public String toString() {
return x + " " + y + " " + z;
}
}
static boolean isPrime(long num) {
if (num == 1) {
return false;
}
if (num == 2) {
return true;
}
if (num % 2 == 0) {
return false;
}
if (num == 3) {
return true;
}
for (int i = 3; i <= Math.sqrt(num) + 1; i += 2) {
if (num % i == 0) {
return false;
}
}
return true;
}
public static void prefixSum(int[] a) {
for (int i = 1; i < a.length; i++) {
a[i] = a[i] + a[i - 1];
}
}
public static void suffixSum(long[] a) {
for (int i = a.length - 2; i > -1; i--) {
a[i] = a[i] + a[i + 1];
}
}
static long mod(long a, long b) {
long r = a % b;
return r < 0 ? r + b : r;
}
public static long binaryToDecimal(String w) {
long r = 0;
long l = 0;
for (int i = w.length() - 1; i > -1; i--) {
long x = (w.charAt(i) - '0') * (long) Math.pow(2, l);
r = r + x;
l++;
}
return r;
}
public static String decimalToBinary(long n) {
String w = "";
while (n > 0) {
w = n % 2 + w;
n /= 2;
}
return w;
}
public static boolean isSorted(int[] a) {
for (int i = 0; i < a.length - 1; i++) {
if (a[i] >= a[i + 1]) {
return false;
}
}
return true;
}
public static void print(int[] a) throws IOException {
for (int i = 0; i < a.length; i++) {
log.write(a[i] + " ");
}
log.write("\n");
}
public static void read(int[] a) {
for (int i = 0; i < a.length; i++) {
a[i] = input.nextInt();
}
}
static class gepair {
long x;
long y;
public gepair(long x, long y) {
this.x = x;
this.y = y;
}
@Override
public String toString() {
return x + " " + y;
}
}
static class pair {
int x;
int y;
public pair(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public String toString() {
return x + " " + y;
}
}
static class pai {
long x;
int y;
public pai(long x, int y) {
this.x = x;
this.y = y;
}
@Override
public String toString() {
return x + " " + y;
}
}
public static long LCM(long x, long y) {
return x / GCD(x, y) * y;
}
public static long GCD(long x, long y) {
if (y == 0) {
return x;
}
return GCD(y, x % y);
}
public static void simplifyTheFraction(int a, int b) {
long GCD = GCD(a, b);
System.out.println(a / GCD + " " + b / GCD);
}
static class Kattio extends PrintWriter {
private BufferedReader r;
private StringTokenizer st;
// standard input
public Kattio() {
this(System.in, System.out);
}
public Kattio(InputStream i, OutputStream o) {
super(o);
r = new BufferedReader(new InputStreamReader(i));
}
// USACO-style file input
public Kattio(String problemName) throws IOException {
super(problemName + ".out");
r = new BufferedReader(new FileReader(problemName + ".in"));
}
// returns null if no more input
String nextLine() {
String str = "";
try {
str = r.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
public String next() {
try {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(r.readLine());
}
return st.nextToken();
} catch (Exception e) {
}
return null;
}
public int nextInt() {
return Integer.parseInt(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
public 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 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 | b0617d4ea51b2ee967f7f508d7ffddfa | 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.tdorosz._1729;
import java.util.Scanner;
public class TwoElevators {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int testCases = scanner.nextInt();
scanner.nextLine();
for (int i = 0; i < testCases; i++) {
handleTestCase(scanner);
}
}
private static void handleTestCase(Scanner scanner) {
int[] floors = new int[3];
for (int i = 0; i < 3; i++) {
floors[i] = scanner.nextInt();
}
int waitForA = floors[0] - 1;
int waitForB = Math.abs(floors[1] - floors[2]) + floors[2] - 1;
if (waitForB > waitForA) {
System.out.println(1);
} else if (waitForB < waitForA) {
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 | 2ed52ec6810a1f595326fa9981167bf4 | 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 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 n1=Math.abs(b-c)+Math.abs(c-1);
int 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 | cb832b8f7846fd2c5b36552c0faa8c82 | 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 in = new Scanner(System.in);
int t = in.nextInt();
while (t-- > 0) {
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
int t1 = Math.abs(a - 1);
int t2 = 0;
if(c > b){
t2 += (c - b + c - 1);
}else{
t2 = b - 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 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 | 3dc313a95a39c13ac12efcc679e2cae3 | 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 a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int x = Math.abs(1-a);
int y = Math.abs(b-c);
int z = Math.abs(c-1);
int w = y + z;
if(x < w){
System.out.println("1");
}
else if(w < x){
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 | 12d649d8a39c7650cc2f3440b2c32c62 | 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;
/**
* a ==> the floor of first elevator
* b ==> position of the second elevator heading to c
* c ==> floor number
*
* Get the seconds of (A) heading to ground (a - 1)
* Get the seconds of (B) heading to (C) (max(b, c) - min(b, c)),
* Then Go to the ground (c - 1)
*/
public class TwoElevators {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while (t-- > 0) {
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
int first = a - 1, second = ((Math.max(b, c) - Math.min(b, c)) + c - 1);
System.out.println((first < second) ? 1 : (second < first) ? 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 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 | e6237b56040344d75225a5278ea09ca4 | 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 |
/**
*
* @author Mohammed_Ramadan
*/
import java.util.*;
public class TwoElevators {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
for (int i = 1; i <= t; i++) {
int a = input.nextInt();
int b = input.nextInt();
int c = input.nextInt();
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 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 | 9e4f951adedbc0c3492f5351a99e102c | 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);
long a=in.nextLong();
for (int i = 0; i < a; i++) {
long x=in.nextLong(),y=in.nextLong(), z=in.nextLong();
long test=Math.abs(z-y)+z;
if(x<test)System.out.println("1");
else if(x==test)System.out.println("3");
else if(x>test)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 8 | 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 | 7737a76a6d9921852b68975fc306627a | 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 sc = new Scanner(System.in);
int t = sc.nextInt();
while (t > 0) {
long a = sc.nextLong();
long b = sc.nextLong();
long c = sc.nextLong();
long x = 0, y = 0;
if (a == 1) {
x = 0;
} else {
x = Math.abs(a - 1);
}
y = Math.abs(b - c) + Math.abs(c - 1);
if (x < y) {
System.out.println(1);
} else if (x == y) {
System.out.println(3);
} else {
System.out.println(2);
}
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 8 | 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 | f7ab505efbe70650feb08978988e9f85 | 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 cf3 {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
int t=sc.nextInt();
for(int k=0;k<t;k++){
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int d=1;
if(b>c){
if((a)==b){
System.out.println(3);
}
else if((a)>b){
System.out.println(2);
}
else if((a)<b){
System.out.println(1);
}
}
else{
if((a-d)==Math.abs(c-b)+(c-d)){
System.out.println(3);
}
else if((a-d)>Math.abs(c-b)+(c-d)){
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 8 | 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 | 32dfdfc56cc3ec67df6846c959b5ec86 | 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 Tttest {
public static int fun(long a,long b,long c) {
long timeA=a-1;
long timeB=0;
if(b<c) {
timeB=c-b;
timeB+=(c-1);
}else if(c<b) {
timeB=b-1;
}else {
timeB=b-1;
}
if(timeA>timeB) {
return 2;
}else if(timeA<timeB) {
return 1;
}else {
return 3;
}
}
public static void main(String[] args){
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>=0){
String s=sc.nextLine();
long a=0,b=0,c=0;
String sub="";
int cnt=0;
for(int i=0;i<s.length();i++) {
char ch=s.charAt(i);
sub+=ch;
if(ch==' ') {
sub=sub.trim();
cnt++;
if(cnt==1) {
a=Long.parseLong(sub);
}else if(cnt==2) {
b=Long.parseLong(sub);
}
sub="";
continue;
}
if(i==s.length()-1) {
c=Long.parseLong(sub);
}
}
//System.out.println(s);
if(a!=0&&b!=0&&c!=0) {
int ans=fun(a,b,c);
System.out.println(ans);
}
t--;
}
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 8 | 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 | e0cb3eb86babd18a1ce0b44bc5b83242 | 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.math.BigInteger;
import java.util.*;
public class Exercise5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a= sc.nextInt();
for (int i = 0; i < a; i++) {
int b= sc.nextInt();
int c= sc.nextInt();
int d=sc.nextInt();
if(b-1>Math.abs(c-d)+(d-1)){
System.out.println(2);
}else if(b-1<Math.abs(c-d)+(d-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 8 | 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 | fbb8757b811403d5f8b11a33b74f2f29 | 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 boolean isPrime(int num){
if(num==0||num==1)
return false;
for(int i=2;i<=num/2;i++){
if(num%i==0)
return false;
}
return true;
}
public static long gcd(long a, long b)
{
if(b==0)
return a;
else
return gcd(b, a%b);
}
public static long lcm(long a, long b)
{
return (a / gcd(a, b)) * b;
}
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 t1=0;
long t2=0;
t1=a-1;
t2=Math.abs(b-c)+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 8 | 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 | 62a860578e86de9d6082976e98e307f5 | 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_Two_Elevators{
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();
// if(a==1 || (c!=1 && (a-1)<(Math.abs(c-b)+c-1)) ||(c==1 && (a-1) < (b-c) ))
// {
// System.out.println(1);
// }
// else if((c==1 && (a-1)>(b-c))||(c!=1 && (a-1) > (c-b+c-1) ))
// {
// System.out.println(2);
// }
// else if((c!=1 && (a-1) == (c-b+c-1) )|| (c==1 && (a-1)==(b-c)) )
// {
// System.out.println(3);
// }
if(a-1<Math.abs(c-b)+c-1)
{
System.out.println(1);
}
else if(a-1>Math.abs(c-b)+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 8 | 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 | 112b6aca81b28b75fe0c740164713783 | 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 Coding {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] answers = new int[n];
for (int i = 0; i < n; i++) {
int[] floors = new int[3];
for (int j = 0; j < floors.length; j++) {
floors[j] = scan.nextInt();
}
if (floors[0] - 1 == (Math.abs(floors[2] - floors[1])) + floors[2] - 1){
answers[i] = 3;
}else if (floors[0] - 1 > (Math.abs(floors[2] - floors[1])) + floors[2] - 1){
answers[i] = 2;
}else{
answers[i] = 1;
}
}
for (int i = 0; i < n; i++) {
System.out.println(answers[i]);
}
}
}
| 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 8 | 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 | b89eb85fc2c26a2f369aac187aa7eea1 | 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();
int timea=0;int timeb=0;
for(int i=0;i<n;i++)
{
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
timea=Math.abs(a-1);
timeb=Math.abs(b-c)+Math.abs(c-1);
if(timea<timeb)
System.out.println(1);
else if(timea>timeb)
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 8 | 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 | d373a21da4e83a769fea452480971c13 | 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{
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 diff = Math.abs(b-c) +c ;
if(a<diff)
System.out.println(1);
else if( a > diff)
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 8 | 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 | c5db944260f3b83a69fb3c5d5771b39c | 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.Map;
import java.util.Scanner;
public class ssss {
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 time1 = a - 1;
int time2 = Math.abs(b-c) + c - 1;
if(time1 == time2){
System.out.println(3);
}
else if(time1 < time2){
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 8 | 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 | fd0782bf6d7b9065b0cf94a2e3ff1527 | 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.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
@SuppressWarnings("unchecked")
public class CodeForces{
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 l1 = a - 1;
int l2 = Math.abs(c - b) + (c - 1);
if(l1 == l2){
System.out.println(3);
}
else if(l1 < l2){
System.out.println(1);
}
else if(l2 < l1){
System.out.println(2);
}
}
}
public static void ShiftToRight(int a[],int n){
int temp = a[n];
for (int i = n; i > 0; i--) {
a[i] = a[i-1];
}
a[0] = temp;
System.out.println("Array after shifting to right by one : "+Arrays.toString(a));
}
public static int binarysearch(int low, int high, int target, int[] nums){
if(low <= high){
int mid = (low + high) / 2;
if(nums[mid] == target){
return mid;
}
else if(nums[mid] < target){
return binarysearch(mid + 1, high, target, nums);
}
else if(nums[mid] > target){
return binarysearch(low, mid - 1, target,nums);
}
}
return -1;
}
public static void reverse(int[] arr){
// Length of the array
int n = arr.length;
// Swaping the first half elements with last half
// elements
for (int i = 0; i < n / 2; i++) {
// Storing the first half elements temporarily
int temp = arr[i];
// Assigning the first half to the last half
arr[i] = arr[n - i - 1];
// Assigning the last half to the first half
arr[n - i - 1] = temp;
}
}
static int recursive_lower_bound(int low, int high, int target, int[] arr){
// Base Case
if (low > high) {
return low;
}
// Find the middle index
int mid = low + (high - low) / 2;
// If key is lesser than or equal to
// array[mid] , then search
// in left subarray
if (target <= arr[mid]){
return recursive_lower_bound(low, mid - 1, target, arr);
}
// If key is greater than array[mid],
// then find in right subarray
return recursive_lower_bound(mid + 1, high,
target, arr);
}
public static void printInteger(List<Integer> list){
for(int i = 0;i < list.size();i++){
System.out.print(list.get(i) + " ");
}
}
public static void printString(List<String> list){
for(int i = 0;i < list.size();i++){
System.out.print(list.get(i));
}
}
public static void printArray(int[] arr){
for(int i = 0;i < arr.length;i++){
System.out.print(arr[i] + " ");
}
}
public static void sortArray(int[] arr){
Arrays.sort(arr);
}
public static void ShiftedToNPositions(int[] nums,int k){
for(int i = 0; i < k; i++){
int j, last;
//Stores the last element of array
last = nums[nums.length-1];
for(j = nums.length-1; j > 0; j--){
//Shift element of array by one
nums[j] = nums[j-1];
}
//Last element of array will be added to the start of array.
nums[0] = last;
}
for(int i = 0;i < nums.length;i++){
System.out.print(nums[i] + " ");
}
}
}
class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
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());
}
}
| 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 8 | 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 | ca5f711d9a92aad1fb1767911e1953b3 | 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 a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d =Math.abs(b-c)+Math.abs(c-1);
if(d==Math.abs(a-1)){
System.out.println(3);
}
else if(d<Math.abs(a-1)){
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 8 | 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 | 6e4a844d88e07ff4a86e2675e82edd05 | 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 javass;
import java.util.Scanner;
public class javass
{
static Scanner stdin=new Scanner(System.in);
public static int read(){
return stdin.nextInt();
}
public static void main(String args[]){
for(int t=read();t>0;t--){
int a=read(),b=read(),c=read();
int tmp1=Math.abs(a-1),tmp2=Math.abs(b-c)+Math.abs(c-1);
if(tmp1==tmp2) System.out.printf("3\n");
else if(tmp1>tmp2) System.out.printf("2\n");
else System.out.printf("1\n");
}
// stdin.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 8 | 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 | 8ca28b052725c1e66234e490f0ca5a2e | 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.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import javax.lang.model.util.ElementScanner6;
import javax.sound.midi.SysexMessage;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
public class Solution {
static HashMap<Integer, Integer> createHashMap(int arr[]) {
HashMap<Integer, Integer> hmap = new HashMap<Integer, Integer>();
for (int i = 0; i < arr.length; i++) {
Integer c = hmap.get(arr[i]);
if (hmap.get(arr[i]) == null) {
hmap.put(arr[i], 1);
}
else {
hmap.put(arr[i], ++c);
}
}
return hmap;
}
public static void Sort2DArrayBasedOnColumnNumber(int[][] array, final int columnNumber) {
Arrays.sort(array, new Comparator<int[]>() {
@Override
public int compare(int[] first, int[] second) {
if (first[columnNumber - 1] > second[columnNumber - 1])
return 1;
else
return -1;
}
});
}
public static int findMax(ArrayList<Integer> arr, int index, int index2) {
int max = 0;
for (int i = index; i < index2; i++) {
max = Math.max(arr.get(i), max);
}
return max;
}
public static int findmin(ArrayList<Integer> arr, int index, int index2) {
int min = 0;
for (int i = index; i < index2; i++) {
min = Math.min(arr.get(i), min);
}
return min;
}
public static void fillarray(int[] arr, final StringTokenizer tk) {
for (int i = 0; i < arr.length; i++) {
arr[i] = parseInt(tk.nextToken());
}
}
static int parseInt(String str) {
return Integer.parseInt(str);
}
static String noZeros(char[] num) {
String str = "";
for (int i = 0; i < num.length; i++) {
if (num[i] == '0')
continue;
else
str += num[i];
}
return str;
}
public static boolean checker(String str) {
String regex = "\\d+";
return str.matches(regex);
}
public static String sortString(String inputString) {
// Converting input string to Character array
Character tempArray[] = new Character[inputString.length()];
for (int i = 0; i < inputString.length(); i++) {
tempArray[i] = inputString.charAt(i);
}
// Sort, ignoring case during sorting
Arrays.sort(tempArray, new Comparator<Character>() {
// Method 2
// To compare characters
@Override
public int compare(Character c1, Character c2) {
// Ignoring case
return Character.compare(
Character.toLowerCase(c1),
Character.toLowerCase(c2));
}
});
// Using StringBuilder to convert Character array to
// String
StringBuilder sb = new StringBuilder(tempArray.length);
for (Character c : tempArray)
sb.append(c.charValue());
return sb.toString();
}
public static int findReds(String str) {
int count = 0;
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == 'R')
count++;
}
return count;
}
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer tk;
int t = parseInt(br.readLine());
int n;
String str = "";
ArrayList<Integer> arr = new ArrayList<Integer>();
int val;
int val2;
while (t-- != 0) {
str = br.readLine();
tk = new StringTokenizer(str);
for (int i = 0; i < 3; i++)
arr.add(parseInt(tk.nextToken()));
val = Math.abs(arr.get(1) - arr.get(2)) + arr.get(2);
if (arr.get(0) < val)
System.out.println(1);
else if (arr.get(0) > val)
System.out.println(2);
else
System.out.println(3);
arr.clear();
}
}
}
/*
* 00101
* 00100
* 00011]
* imrtu
* 2 1 1
* 2 2 1
* 2 2 2
* 2 2 3
* 2 2 4
* 2 2 5
* 2 2 6
* 2 2 7
* 2 2 8
* 2 2 9
* 2 2 10
* 2 3 1
* 3 2 1
* 3 3 1
* 3 4 1
* 3 5 1
* 3 6 1
* 3 7 1
* 3 8 1
* 3 8 2
* 3 8 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 8 | 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 | 69633dbc7a7245e55287636c419e0f93 | 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 s=new Scanner(System.in);
int t=s.nextInt();
while(t>0)
{
long a[]=new long[3];
for(int i=0;i<3;i++)
{
a[i]=s.nextInt();
}
long com=(a[2]-a[1]);
if(com<0)
{
com=-com;
}
long ans=com+a[2]-1;
long dom=a[0]-1;
if(ans>dom)
{
System.out.println(1);
}
else if(ans<dom)
{
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 8 | 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 | c47bb0ed358e882844bb5db3a42e6136 | 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 practicing;
import java.io.*;
import java.lang.*;
import java.math.BigInteger;
import java.util.*;
public class test {
public static Comparator<String> getComp(){
return new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return 1;
}
};
}
public static Comparator<Integer> getComp2(){
return new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return o1>o2?1:-1;
}
};
}
//-------------------------------------------------------------------------------------------------------------------//
public static void main(String[] argus) throws IOException {
Flash flash = new Flash(System.in);
BufferedWriter sout=new BufferedWriter(new OutputStreamWriter(System.out));
int t=flash.nextInt();
for(int i=0;i<t;i++){
long a=flash.nextLong(),b= flash.nextLong(),c= flash.nextLong();
a-=1;
b=Math.abs(b-c);
b+=Math.abs(c-1);
if(a<b)sout.write("1\n");
else if(b<a)sout.write("2\n");
else sout.write("3\n");
}
sout.close();
}
//------------------------------------------------------------------------------------------------------------------//
}
class Pair {
private long left;
private long right;
public Pair(long left,long right) {
this.left=left;
this.right=right;
}
public long getLeft() {
return this.left;
}
public long getRight() {
return this.right;
}
public void setLeft(long left) {
this.left=left;
}
public void setRight(long right) {
this.right=right;
}
public static Pair[] sort(Pair[] pairs) {
Arrays.sort(pairs);
return pairs;
}
public static void toString(Pair[] pairs) {
for (int i = 0; i < pairs.length; i++) {
System.out.print(pairs[i].getLeft() +" "+pairs[i].getRight());
System.out.println();
}
}
}
class Flash{
StringTokenizer st;
BufferedReader br;
public Flash(File file) throws FileNotFoundException {
br=new BufferedReader(new FileReader(file));
}
public Flash(InputStream system) {
br = new BufferedReader(new InputStreamReader(system));
}
public String next() throws IOException {
while(st==null||!st.hasMoreTokens())
st=new StringTokenizer (br.readLine());
return st.nextToken();
}
public int nextInt() throws NumberFormatException, IOException {
return Integer.parseInt(next());
}
public double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public long nextLong() throws IOException {
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 8 | 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 | 8590a7b8808f17f276ade896ea2b8e07 | 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.ArrayList;
import java.util.StringTokenizer;
public class CodeForces {
public static void main(String[] args) {
StringBuilder stringBuilder = new StringBuilder();
FastReader fastReader = new FastReader();
int n = fastReader.nextInt();
int[][] arr = new int[n][3];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
arr[i][j] = fastReader.nextInt();
}
int x = arr[i][0] - 1;
int y = Math.abs(arr[i][1] - arr[i][2]) + arr[i][2] - 1;
if(x < y) {
System.out.println("1");
}else if(x == y) {
System.out.println("3");
}else System.out.println("2");
}}
// long x1 = fastReader.nextLong();
// long y1 = fastReader.nextLong();
// long x2 = fastReader.nextLong();
// long y2 = fastReader.nextLong();
// long[][] arr = new long[fastReader.nextInt()][2];
// for (int i = 0; i < arr.length; i++) {
// for (int j = 0; j < 2; j++) {
// arr[i][j] = fastReader.nextInt();
// }
// }
// long count = 0;
// ArrayList<Integer> a = new ArrayList<>();
// for (int i = 0; i < arr.length; i++) {
// int x = (int) Math.sqrt(Math.pow((x1 - arr[i][0]), 2) + Math.pow((y1- arr[i][1]), 2));
// int y = (int) Math.sqrt(Math.pow((x2 - arr[i][0]), 2) + Math.pow((y2- arr[i][1]), 2));
// if(x < y) {
// a.add(i+1);
// }
// }
// if(a.size() == 0) {
// System.out.println("NO");
// }else for(double b : a) {
// System.out.println((int) b);
// }
// if (!flag)
// System.out.println(num + " is a prime number.");
// else
// System.out.println(num + " is not a prime number.");
// System.out.println(c1 );
// System.out.println(c2);
}
class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader(String s) {
try {
br = new BufferedReader(new FileReader(s));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public FastReader() {
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();
}
String nextLine() {
String str = "";
try {
if (st.hasMoreTokens()) {
str = st.nextToken("\n");
} else {
str = br.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
int nextInt() {
return Integer.parseInt(nextToken());
}
long nextLong() {
return Long.parseLong(nextToken());
}
double nextDouble() {
return Double.parseDouble(nextToken());
}
}
| 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 8 | 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 | 3714ee08929bfb13c014747f362b5022 | 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 {
public static void main(String[] args) throws IOException {
FastScanner sc =new FastScanner();
PrintWriter w =new PrintWriter(System.out);
int n = sc.nextInt();
while (n-- !=0){
int a =sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
if (a==1){
w.println(1);
continue;
}
if (c>b ){
if ((Math.abs(b-c)+Math.abs(c-1))==a-1){
w.println(3);
}else if ((Math.abs(b-c)+Math.abs(c-1))<a-1){
w.println(2);
}else {
w.println(1);
}
}else {
if (Math.abs(b-1) <a-1){
w.println(2);
}else if (Math.abs(b-1) ==a-1){
w.println(3);
}else {
w.println(1);
}
}
}
w.flush();
}
public static class FastScanner {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public FastScanner() throws IOException {
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
private short nextShort() throws IOException {
short ret = 0;
byte c = read();
while (c <= ' ') c = read();
boolean neg = (c == '-');
if (neg) c = read();
do ret = (short) (ret * 10 + c - '0');
while ((c = read()) >= '0' && c <= '9');
if (neg) return (short) -ret;
return ret;
}
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;
}
private char nextChar() throws IOException {
byte c = read();
while (c <= ' ') c = read();
return (char) c;
}
private String nextString() throws IOException {
StringBuilder ret = new StringBuilder();
byte c = read();
while (c <= ' ') c = read();
do {
ret.append((char) c);
} while ((c = read()) > ' ');
return ret.toString();
}
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++];
}
}
}
| 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 8 | 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 | fbdda7555247da94cac9191111b7340d | 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 k=0;k<T;k++)
{
long a=sc.nextInt();
long b=sc.nextInt();
long c=sc.nextInt();
long first=(a-1);
long second=0;
if(b>c)
{
second+=(b-1);
}
else
{
second+=(c-b);
second+=(c-1);
}
// System.out.println(first+" "+second);
if(first>second)
System.out.println("2");
else if(second>first)
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 8 | 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 | 4810687c09bf7fd86bd839b7fc6d0b99 | 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
{
Scanner in = new Scanner(System.in);
int test = in.nextInt();
int a = 0, b =0 ,c =0;
while(test-- > 0 ) {
a= in.nextInt();
b = in.nextInt();
c = in.nextInt();
int elevator = (Math.abs(b-c)+c);
if(a>elevator){
System.out.println(2);
}
else if (a<elevator){
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 8 | 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 | c88c58b8dddb8888222c03aeef62f837 | 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 x {
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int test=sc.nextInt();
while(test-->0)
{
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
if(a==1)
{
System.out.println("1");
}
else
{
int a_1=Math.abs(a-1);
while(b==1 || b>1)
{
int f=Math.abs(c-b)+Math.abs(c-1);
if(a_1>f)
{
System.out.println("2");
break;
}
else if(a_1==f)
{
System.out.println("3");
break;
}
else
{
System.out.println("1");
break;
}
}
}
}
}
}
| 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 8 | 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 | c7f64f12c623997adc044b0706ed5e9b | 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;
public class TwoLifts {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int input[] = getInts(reader.readLine().trim());
int amountOfNumbers=input[0];
for (int i=0;i<amountOfNumbers;i++){
input = getInts(reader.readLine().trim());
int a= input[0];
int b= input[1];
int c= input[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);
}
}
}
public static int[] getInts(String s) {
s = s.replaceAll(" ", " ");
String toParse[] = s.split(" ");
int toReturn[] = new int[toParse.length];
for (int i = 0; i < toParse.length; i++) {
toReturn[i] = Integer.parseInt(toParse[i]);
}
return toReturn;
}
} | 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 8 | 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 | 081bc13fbbab5a74d0bbd445c1386d08 | 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 TwoLifts {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int amountOfNumbers=scan.nextInt();
for (int i=0;i<amountOfNumbers;i++){
int a= scan.nextInt();
int b= scan.nextInt();
int c= scan.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 8 | 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 | 69d9d31fcc116904ac46e24b89bc96a0 | 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;
/**
*
* @author devil
*/
public class Codeforces {
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();
int d=a-1;
int d1=Math.abs(b-c)+Math.abs(c-1);
int ans=0;
if(d<=d1){
ans+=1;
}
if(d>=d1){
ans+=2;
}
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 8 | 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 | 598bf1cb617f3b641a4e0488cd0aca4d | 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();
while(t-- > 0) {
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int f = a - 1;
int s = 0;
if(c > b) {
s = (c - b);
}
s += Math.max(c, b) - 1;
if(f > s) {
System.out.println(2);
}else if(f < s){
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 8 | 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 | 8cd40db4ead9548ef889a5891107c4d2 | 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 TwoElevetorsCodeForces
{
public static void main(String[] args) {
Scanner as=new Scanner(System.in);
int t, a, b, c;
t=as.nextInt();
while(t--!=0){
a=as.nextInt(); b=as.nextInt(); c=as.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 8 | 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 | 74d76fc6c68dfe525f7aa70e30b5ccaf | 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.math.BigInteger;
import java.util.*;
import java.io.BufferedReader;
import javax.print.DocFlavor;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class lol {
static Scanner in = new Scanner(System.in);
static FastScanner scanner = new FastScanner();
public static void main(String[] args) {
int a = 1;
while (a-- > 0) {
solve();
}
}
public static void solve() {
int q= in.nextInt();
for (int i = 0; i <q ; i++) {
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
// System.out.println(b);
if(Math.abs(b - c) + Math.abs(c - 1) < Math.abs(a - 1)){
System.out.println(2);
}else if(Math.abs(b - c) + Math.abs(c - 1) > Math.abs(a - 1)){
System.out.println(1);
}else{
System.out.println(3);
}
// }
}
}
public static boolean isPowerOfTwo(long n)
{
if (n == 0)
return false;
while (n != 1) {
if (n % 2 != 0)
return false;
n = n / 2;
}
return true;
}
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 8 | 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 | 4ac119bb4b48bd8d2ba757a0309b77ab | 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.Scanner;
public class leet {
public static void main(String[] args) {
Scanner shyn = new Scanner(System.in);
ArrayList<Integer> numbers = new ArrayList<Integer>();
int a = shyn.nextInt();
int c = 0;
for (int i = 0; i < a; i++) {
int n1 = shyn.nextInt();
int n2 = shyn.nextInt();
int n3 = shyn.nextInt();
if (n2 > n3 && n2 > 1) {
c = n2 - 1;
}
else {
c = 2 * n3 - n2 - 1;
}
if (n1 - 1 < (c)) {
numbers.add(1);
} else if (n1 - 1 > (c)) {
numbers.add(2);
} else if (n1 - 1 == (c)) {
numbers.add(3);
}
}
for(int co : numbers){
System.out.println(co);
}
}
}
| 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 8 | 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 | b335dcdf4afe39b448ebacc9d5cf438b | 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 freecode {
public static void main(String[]args) {
Scanner sc = new Scanner(System.in);
int h = sc.nextInt(), t1, t2;
int a, b, c;
for(int i = 0; i < h; i++){
a = sc.nextInt();b = sc.nextInt(); c = sc.nextInt();
t1 = a-1;
t2 = Math.abs(b-c)+c-1;
if(t1 == t2){
System.out.println("3");
}
else if(t1 > t2){
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 8 | 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 | 37061a0f0273d274e41f8f0b7f6e8520 | 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 {
static class Reader {
public BufferedReader br;
StringTokenizer st = new StringTokenizer("");
public Reader() {
this(System.in);
}
public Reader(InputStream input) {
br = new BufferedReader(new InputStreamReader(input));
}
String next() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int ni() {
return Integer.parseInt(next());
}
long nl() {
return Long.parseLong(next());
}
double nd() {
return Double.parseDouble(next());
}
String nextl() {
String str = "";
try {
str = br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
int[] arrin(long num) {
int n = (int) num;
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = ni();
return a;
}
long[] arrnl(long num) {
int n = (int) num;
long[] l = new long[n];
for (int i = 0; i < n; i++) l[i] = nl();
return l;
}
}
//<------------------------------------------------WRITER---------------------------->
static class Writer {
static PrintWriter out;
public Writer() {
this(System.out);
}
public Writer(OutputStream outs) {
out = new PrintWriter(outs);
}
public void pl(int i) {
out.println(i);
}
public void pl(long l) {
out.println(l);
}
public void pl(double d) {
out.println(d);
}
public void pl(String s) {
out.println(s);
}
public void p(int i) {
out.print(i);
}
public void p(long l) {
out.print(l);
}
public void p(double d) {
out.print(d);
}
public void p(String s) {
out.print(s);
}
public void p() {
out.println();
}
public void close() {
out.close();
}
}
//----------------------------------------------------------------------------------->
//--------------------------VARIABLES------------------------------------//
static Reader in = new Reader();
static OutputStream outputStream = System.out;
static Writer out = new Writer(outputStream);
static long lmax = Long.MAX_VALUE, lmin = Long.MIN_VALUE;
static int imax = Integer.MAX_VALUE, imin = Integer.MIN_VALUE;
static long mod = 1000000007;
//-----------------------------------------------------------------------//
//--------------------------Red_Hair-----------------------------------//
private static void Red_Hair() throws IOException {
String FILE = "RED";
try { FILE = System.getProperty("user.dir"); }
catch (Exception e) { }
if(new File(FILE).getName().equals("CP")) {
out = new Writer(new FileOutputStream("output.txt"));
in = new Reader(new FileInputStream("input.txt"));
}
}
//-----------------------------------------------------------------------//
public static void main(String[] args) throws IOException {
Red_Hair();
int t = in.ni();
while (t-- > 0)
solve();
out.close();
}
static void solve() throws IOException {
int n = in.ni();
int m = in.ni();
int q = in.ni();
if(n == 1){
out.pl(1);
return;
}
int sr = n-1;
int ssr1;
ssr1 =Math.abs(q-m);
ssr1 += q-1;
if(sr<ssr1){
out.pl(1);
} else if (ssr1 < sr) {
out.pl(2);
}else{
out.pl(3);
}
}
static class pr <T extends Comparable<T>, V extends Comparable<V>> implements Comparable<pr<T, V>> {
T a;
V b;
public pr(T a, V b) {
this.a = a;
this.b = b;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof pr)) return false;
pr<?, ?> pr = (pr<?, ?>) o;
return a.equals(pr.a) && b.equals(pr.b);
}
@Override
public int hashCode() {
return Objects.hash(a, b);
}
@Override
public int compareTo(pr o) {
return this.a.compareTo(((T) o.a));
}
}
} | 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 8 | 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 | cc1f56a717f45e4164f77b6945c11578 | 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 {
static class Reader {
public BufferedReader br;
StringTokenizer st = new StringTokenizer("");
public Reader() {
this(System.in);
}
public Reader(InputStream input) {
br = new BufferedReader(new InputStreamReader(input));
}
String next() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int ni() {
return Integer.parseInt(next());
}
long nl() {
return Long.parseLong(next());
}
double nd() {
return Double.parseDouble(next());
}
String nextl() {
String str = "";
try {
str = br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
int[] arrin(long num) {
int n = (int) num;
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = ni();
return a;
}
long[] arrnl(long num) {
int n = (int) num;
long[] l = new long[n];
for (int i = 0; i < n; i++) l[i] = nl();
return l;
}
}
//<------------------------------------------------WRITER---------------------------->
static class Writer {
static PrintWriter out;
public Writer() {
this(System.out);
}
public Writer(OutputStream outs) {
out = new PrintWriter(outs);
}
public void pl(int i) {
out.println(i);
}
public void pl(long l) {
out.println(l);
}
public void pl(double d) {
out.println(d);
}
public void pl(String s) {
out.println(s);
}
public void p(int i) {
out.print(i);
}
public void p(long l) {
out.print(l);
}
public void p(double d) {
out.print(d);
}
public void p(String s) {
out.print(s);
}
public void p() {
out.println();
}
public void close() {
out.close();
}
}
//----------------------------------------------------------------------------------->
//--------------------------VARIABLES------------------------------------//
static Reader in = new Reader();
static OutputStream outputStream = System.out;
static Writer out = new Writer(outputStream);
static long lmax = Long.MAX_VALUE, lmin = Long.MIN_VALUE;
static int imax = Integer.MAX_VALUE, imin = Integer.MIN_VALUE;
static long mod = 1000000007;
//-----------------------------------------------------------------------//
//--------------------------Red_Hair-----------------------------------//
private static void Red_Hair() throws IOException {
String FILE = "RED";
try { FILE = System.getProperty("user.dir"); }
catch (Exception e) { }
if(new File(FILE).getName().equals("CP")) {
out = new Writer(new FileOutputStream("output.txt"));
in = new Reader(new FileInputStream("input.txt"));
}
}
//-----------------------------------------------------------------------//
public static void main(String[] args) throws IOException {
Red_Hair();
int t = in.ni();
while (t-- > 0)
solve();
out.close();
}
static void solve() throws IOException {
int n = in.ni();
int m = in.ni();
int q = in.ni();
if(n==1) {
out.pl(n);
return;
}
int sr1 = Math.abs(n-1);
int sr2= Math.abs(m-q)+(q-1);
if(sr1<sr2){
out.pl(1);
} else if (sr2<sr1) {
out.pl(2);
}else{
out.pl(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 8 | 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 | cfde71fb9d969d20e77489cd32b6f2f1 | 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) {
// TODO Auto-generated method stub
Scanner scn = new Scanner(System.in);
long t = scn.nextInt();
for(long i = 0;i<t;i++) {
long a = scn.nextLong();
long b = scn.nextLong();
long c = scn.nextLong();
long e = Math.abs(b-c)+c;
if(a>e) {
System.out.println("2");
}else if (e>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 8 | 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 | 8d3d22abe575e61e93c27ad6582b1fa2 | 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 TwoElevators
{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
while(t-->0)
{
String s[] = br.readLine().split(" ");
int x = Integer.parseInt(s[0]);int y = Integer.parseInt(s[1]);int z = Integer.parseInt(s[2]);
int a = Math.abs(x-1);
int b = Math.abs(y-z) + Math.abs(z-1);
if(b>a) 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 8 | 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 | 64819209f87c369d9bc2c343502d2ead | 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 leetcode {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int i = 0 ; i<t ; i++) {
long a = sc.nextLong();
long b = sc.nextLong();
long c = sc.nextLong();
long x = a-1;
long y = 0;
if(c>=b) {
y = (c-b) + c-1;
}
else{
y = (b-c) + c-1;
}
if(x>y) {
System.out.println(2);
}
else if(y>x) {
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 8 | 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 | c2566af0bbec450ebe6485da640061bf | 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++){
sc.nextLine();
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
a=a-1;
if(c>b){
b=(c-b)+(c-1);
}
else{
b=b-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 8 | 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 | c8ff13dd491eb126cf1d99652a543195 | 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_Two_Elevators{
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();
if(b>c){
if(a>b){
System.out.println(2);
}
else if(b>a){
System.out.println(1);
}
else{
System.out.println(3);
}
}
else if(c>b){
int diff1=a-1;
int diff2=((c-b)+(c-1));
if(diff1>diff2){
System.out.println(2);
}
else if(diff1<diff2){
System.out.println(1);
}
else{
System.out.println(3);
}
}
else{
int p=a-1;
int q=b-1;
if(p>q){
System.out.println(2);
}
else if(q>p){
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 8 | 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 | 404a641bbfb26394ddf4517180c724d3 | 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 com.sun.jdi.Value;
import java.io.*;
import java.util.*;
public class Main {
// static long gcd(long a, long b) {
// if (a == 0) return b;
// return b == 0 ? a : gcd(b, a % b);
// }
// static int lcm(int a, int b) { return (a * b)/gcd(a, b); }
public static void main(String[] args) throws Exception {
PrintWriter pw = new PrintWriter(System.out);
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
int dis1 = a - 1, dis2 = Math.abs(b - c) + c - 1;
if (dis1 > dis2) pw.println(2);
else if (dis2 > dis1) pw.println(1);
else pw.println(3);
}
pw.close();
}
static class pair {
int left, right;
public pair(int left, int right) {
this.left = left;
this.right = right;
}
}
// static int bs(int l, int h, ArrayList<Integer> al, int val) {
// int mid = 0;
// while (l <= h) {
// mid = l + h >> 1;
// if (al.get(mid) == val) return mid;
// if (al.get(mid) > val) h = mid - 1;
// else l = mid + 1;
// }
// return mid;
// }
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec) f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public boolean ready() throws IOException {
return br.ready();
}
}
} | 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 8 | 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 | 26ac974be6c60a10da033a94569faa1c | 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.io.*;
import java.util.*;
public class Cf_0 {
private static class FastReader {
InputStream is;
private byte[] inbuf = new byte[1024];
private int lenbuf = 0, ptrbuf = 0;
public FastReader(InputStream is) {
this.is = is;
}
public int readByte() {
if (lenbuf == -1) throw new InputMismatchException();
if (ptrbuf >= lenbuf) {
ptrbuf = 0;
try {
lenbuf = is.read(inbuf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (lenbuf <= 0) return -1;
}
return inbuf[ptrbuf++];
}
public boolean isSpaceChar(int c) {
return !(c >= 33 && c <= 126);
}
private boolean isEndOfLine(int c) {
return c == '\n' || c == '\r' || c == -1;
}
public int skip() {
int b;
while ((b = readByte()) != -1 && isSpaceChar(b)) ;
return b;
}
public String next() {
int b = skip();
StringBuilder sb = new StringBuilder();
while (!(isSpaceChar(b))) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public String nextLine() {
int c = skip();
StringBuilder sb = new StringBuilder();
while (!isEndOfLine(c)) {
sb.appendCodePoint(c);
c = readByte();
}
return sb.toString();
}
public int nextInt() {
int num = 0, b;
boolean minus = false;
while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
if (b == '-') {
minus = true;
b = readByte();
}
while (true) {
if (b >= '0' && b <= '9') {
num = (num << 3) + (num << 1) + (b - '0');
} else {
return minus ? -num : num;
}
b = readByte();
}
}
public long nextLong() {
long num = 0;
int b;
boolean minus = false;
while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
if (b == '-') {
minus = true;
b = readByte();
}
while (true) {
if (b >= '0' && b <= '9') {
num = (num << 3) + (num << 1) + (b - '0');
} else {
return minus ? -num : num;
}
b = readByte();
}
}
public double nextDouble() {
return Double.parseDouble(next());
}
public char[] next(int n) {
char[] buf = new char[n];
int b = skip(), p = 0;
while (p < n && !(isSpaceChar(b))) {
buf[p++] = (char) b;
b = readByte();
}
return n == p ? buf : Arrays.copyOf(buf, p);
}
public char readChar() {
return (char) skip();
}
public long[] readArrayL(int n) {
long[] arr = new long[n];
for (int i = 0; i < n; i++) arr[i] = nextLong();
return arr;
}
public int[] readArray(int n) {
int[] arr = new int[n];
for (int i = 0; i < n; i++) arr[i] = nextInt();
return arr;
}
}
private static PrintWriter pw= new PrintWriter(System.out);
private static FastReader fr= new FastReader(System.in);
public static void main(String[] args) throws IOException {
int t= fr.nextInt();
for(int i=0;i<t;i++){
solve800(fr.nextInt(), fr.nextInt(), fr.nextInt());
}
pw.close();
}
public static void solve800(int a,int b,int c){
int bDist= (b>=c)? (b-1): (c-b)+(c-1);
int aDist= (a-1);
if(aDist>bDist)
pwl("2");
else if(bDist>aDist)
pwl("1");
else pwl("3");
}
public static long[]readLong(int n){
long []a= new long[n];
for(int it=0;it<n;it++){
a[it]=fr.nextLong();
}
return a;
}
public static int[] readArray(int n){
int []a= new int[n];
for(int it=0;it<n;it++){
a[it]=fr.nextInt();
}
return a;
}
public static int min(int []a){
int min=a[0];
for(int i=1;i<a.length;i++){
min=Math.min(min,a[i]);
}
return min;
}
public static int max(int []a){
int max=a[0];
for(int i=1;i<a.length;i++){
max=Math.max(max,a[i]);
}
return max;
}
public static int getDown(int n){
if(n==0)
return 9;
else return --n;
}
public static int getUp(int n){
if(n==9)
return 0;
else return ++n;
}
public static long findGCD(long a, long b) {
while(b != 0)
{
if(a > b)
{
a = a - b;
}
else
{
b = b - a;
}
}
return a;
}
public static long lcm(long a, long b) {
return (a / findGCD(a, b)) * b;
}
public static void print(int []a){
StringBuilder sb= new StringBuilder();
for(int t:a){
sb.append(t+" ");
}
pwl(sb.toString());
}
public static void pwl(String s){
pw.println(s);
}
public static void pw(String s){
pw.print(s);
}
}
| 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 8 | 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 | 441a8e0e181ee3102d697160888e1488 | 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 prog1 {
static int solve(int arr[])
{
int ans = 0;
if(arr[0] == 1)
{
return 1;
}
int a = arr[0] - 1;
int b = Math.abs(arr[1] - arr[2]);
if(arr[2] != 1 && arr[2]>arr[1])
{
b = 2*b;
b = b + Math.abs(arr[1] - 1);
}
if(arr[2] !=1 && arr[2]<arr[1])
{
b = b + arr[2] - 1;
}
if(a<b)
{
ans = 1;
}
else if(a == b)
{
ans = 3;
}
else {
ans = 2;
}
return ans;
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int i=1;i<=t;i++)
{
int a[] = new int[3];
for(int j = 0;j<3 ;j++)
{
a[j] = sc.nextInt();
}
int ans = solve(a);
System.out.println(ans);
}
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 8 | 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 |
Subsets and Splits