exec_outcome
stringclasses
1 value
code_uid
stringlengths
32
32
file_name
stringclasses
111 values
prob_desc_created_at
stringlengths
10
10
prob_desc_description
stringlengths
63
3.8k
prob_desc_memory_limit
stringclasses
18 values
source_code
stringlengths
117
65.5k
lang_cluster
stringclasses
1 value
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_time_limit
stringclasses
27 values
prob_desc_sample_outputs
stringlengths
2
796
prob_desc_notes
stringlengths
4
3k
lang
stringclasses
5 values
prob_desc_input_from
stringclasses
3 values
tags
listlengths
0
11
src_uid
stringlengths
32
32
prob_desc_input_spec
stringlengths
28
2.37k
difficulty
int64
-1
3.5k
prob_desc_output_spec
stringlengths
17
1.47k
prob_desc_output_to
stringclasses
3 values
hidden_unit_tests
stringclasses
1 value
PASSED
9c38ce483243ddf0ac33a874d08e6f3d
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.Writer; import java.io.OutputStream...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
221f6f143a422d156542155c594d4d4c
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
7bf9ae64de732432d988a8f7c790f7cd
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.util.*; public class Bai1_extra_Semifinals { public static void main(String[] args) { int nPart; Scanner sc = new Scanner(System.in); nPart = sc.nextInt(); int[][] partResult = new int[nPart][]; // set n participants result for (int i = 0; i < nPart; i...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
0024a744d3589a752abe98d84ba3b19b
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.util.*; public class Bai1_extra_Semifinals { public static void main(String[] args) { /*http://codeforces.com/problemset/problem/378/B*/ int nPart; Scanner sc = new Scanner(System.in); nPart = sc.nextInt(); // int[][] partResult = new int[nPart][]; int[] ...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
55c74ef2209390a684434f9c4f12f3cd
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution ...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
b02153bb17d5490fd0381316d9bf515d
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
//Semifinals import java.util.ArrayList; import java.util.Scanner; public class Main { static int checka[] = new int[(int)1e5 + 1]; static int checkb[] = new int[(int)1e5 + 1]; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n,k,i,j,count,x,y; ArrayList<Integer> a = new Arr...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
400527bc6f7a16108483ab4a2a607f5b
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.util.*; public class RookBishopKing { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a[] = new int[n+1]; int b[] = new int[n+1]; char resA[] = new char[n+1]; char resB[] = new char[n+...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
b6c7a7c59e9f34a9aca7ff8c3fde44b1
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.util.Scanner; /** * * @author SONY */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner sc = new Scanner (System.in); int N = sc.nextInt(); int [] tea...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
c2c259e4b64f748d30690554b3bb17c8
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class semifinals { public static String test(int[] s1, int[] s2, int n) { int k = n/2; int count = 0; int i = 0; int j = 0; int[] str1 = new int[n]; int[] str2 = new int[n]; int countForS1 = 0; int countForS2 = 0; while (count ...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
352c665d6cce6b8cea05923ab4ae2634
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package pkg378bsemifinals; import java.util.*; import java.util.stream.Collectors; /** * * @author King */ public class Main { ...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
5b4e85cda7d0bb1c2e0e015ae66829c5
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class Semifinals { InputStream is; PrintWriter out; String INPUT = ""; long mod = 1000000007; void solve() { int n = ni(); P[] a = n...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
16aab21f683096c63a37aa09eeb7e4a3
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a[][] = new int[2][n], ans[][] = new int[2][n]; for(int i = 0; i < n; ++i) { for(int j = 0; j < 2; ++j) { ...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
731c61da3e0126efcc381b53eeb81563
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.util.*; import javafx.util.Pair; public class mainsource { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); ArrayList<Integer> semi1,semi2,ans1,ans2; semi1=new ArrayList<Integer>(); semi2=new ArrayList<Integer>(); ans1=new ArrayList<Integer>()...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
1d89dcdd110e1489cd13759727bb95b2
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.util.Scanner; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] semi1,semi2,ans1,ans2; semi1 = new int[n]; semi2 = new int[n]; ans1 = new int[n]; ans2 = new int[n]; int k = n / 2; for (int i = 0; i < n; ++i) ...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
9654a3a3343418f68d8f61e98d4905d8
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** *...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
687fedbba8a75202bbfb61f2f6918fd3
train_001.jsonl
1388331000
Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the peopl...
256 megabytes
import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Solution { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { String n = scann...
Java
["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110"]
1 second
["1110\n1100", "1100\n1100"]
NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090. If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals. If k ...
Java 8
standard input
[ "implementation", "sortings" ]
bea30e4ba653b9d0af87fc79b9ec8b4f
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifi...
1,300
Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-t...
standard output
PASSED
23a6388c8f3e8d412287a6d495e74885
train_001.jsonl
1384102800
Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types: Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j that ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public cla...
Java
["4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 8", "4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 13"]
1 second
["YES\n4 7 4 7", "NO"]
null
Java 7
standard input
[ "constructive algorithms", "greedy", "brute force" ]
ae5757df3be42b74076cdf42f7f897cd
The first line contains two integers n and m (1 ≤ n, m ≤ 5000) — the size of the array and the number of operations in Levko's records, correspondingly. Next m lines describe the operations, the i-th line describes the i-th operation. The first integer in the i-th line is integer ti (1 ≤ ti ≤ 2) that describes the oper...
1,700
In the first line print "YES" (without the quotes), if the solution exists and "NO" (without the quotes) otherwise. If the solution exists, then on the second line print n integers a1, a2, ... , an (|ai| ≤ 109) — the recovered array.
standard output
PASSED
30ee7f107d31e60d0529e597116ba9b4
train_001.jsonl
1384102800
Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types: Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j that ...
256 megabytes
import java.util.Scanner; public class C { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n, m; n = in.nextInt(); m = in.nextInt(); int l[] = new int[m]; int r[] = new int[m]; int f[] = new int[m]; int d[] = new int[m...
Java
["4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 8", "4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 13"]
1 second
["YES\n4 7 4 7", "NO"]
null
Java 7
standard input
[ "constructive algorithms", "greedy", "brute force" ]
ae5757df3be42b74076cdf42f7f897cd
The first line contains two integers n and m (1 ≤ n, m ≤ 5000) — the size of the array and the number of operations in Levko's records, correspondingly. Next m lines describe the operations, the i-th line describes the i-th operation. The first integer in the i-th line is integer ti (1 ≤ ti ≤ 2) that describes the oper...
1,700
In the first line print "YES" (without the quotes), if the solution exists and "NO" (without the quotes) otherwise. If the solution exists, then on the second line print n integers a1, a2, ... , an (|ai| ≤ 109) — the recovered array.
standard output
PASSED
586457d7ea211704e6558bd801a3238b
train_001.jsonl
1384102800
Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types: Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j that ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class C { public static void main(String[] args) throws Exception { int elemCnt = nextInt(); int opCnt = nextInt(); int[] ar = new int[elemCnt]; int[]...
Java
["4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 8", "4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 13"]
1 second
["YES\n4 7 4 7", "NO"]
null
Java 7
standard input
[ "constructive algorithms", "greedy", "brute force" ]
ae5757df3be42b74076cdf42f7f897cd
The first line contains two integers n and m (1 ≤ n, m ≤ 5000) — the size of the array and the number of operations in Levko's records, correspondingly. Next m lines describe the operations, the i-th line describes the i-th operation. The first integer in the i-th line is integer ti (1 ≤ ti ≤ 2) that describes the oper...
1,700
In the first line print "YES" (without the quotes), if the solution exists and "NO" (without the quotes) otherwise. If the solution exists, then on the second line print n integers a1, a2, ... , an (|ai| ≤ 109) — the recovered array.
standard output
PASSED
c228379da502e871b01b8dccc4613058
train_001.jsonl
1384102800
Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types: Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j that ...
256 megabytes
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; import java.io.*; public class Main { void solve() { int n = sc.nextInt(); int m = sc.nextInt(); int[][] query = new int[m][4]; for (int i = 0; i < m; i++) for (int j = 0; j < 4; j++) query[i][j] = sc.nextInt(); ...
Java
["4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 8", "4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 13"]
1 second
["YES\n4 7 4 7", "NO"]
null
Java 7
standard input
[ "constructive algorithms", "greedy", "brute force" ]
ae5757df3be42b74076cdf42f7f897cd
The first line contains two integers n and m (1 ≤ n, m ≤ 5000) — the size of the array and the number of operations in Levko's records, correspondingly. Next m lines describe the operations, the i-th line describes the i-th operation. The first integer in the i-th line is integer ti (1 ≤ ti ≤ 2) that describes the oper...
1,700
In the first line print "YES" (without the quotes), if the solution exists and "NO" (without the quotes) otherwise. If the solution exists, then on the second line print n integers a1, a2, ... , an (|ai| ≤ 109) — the recovered array.
standard output
PASSED
4bde9a97ac5cae3b435e0e794d2e7d9f
train_001.jsonl
1384102800
Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types: Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j that ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.StringTokenizer; public class LevkoAndArrayRecovery { public static void main(String[] args) { MyScanner sc = new MyScanner(); final int MAX_VALUE = 100000...
Java
["4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 8", "4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 13"]
1 second
["YES\n4 7 4 7", "NO"]
null
Java 7
standard input
[ "constructive algorithms", "greedy", "brute force" ]
ae5757df3be42b74076cdf42f7f897cd
The first line contains two integers n and m (1 ≤ n, m ≤ 5000) — the size of the array and the number of operations in Levko's records, correspondingly. Next m lines describe the operations, the i-th line describes the i-th operation. The first integer in the i-th line is integer ti (1 ≤ ti ≤ 2) that describes the oper...
1,700
In the first line print "YES" (without the quotes), if the solution exists and "NO" (without the quotes) otherwise. If the solution exists, then on the second line print n integers a1, a2, ... , an (|ai| ≤ 109) — the recovered array.
standard output
PASSED
fe014892b908ba4ab92fbad43f3971f5
train_001.jsonl
1384102800
Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types: Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j that ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class ZadC { public static void main(String... args) throws IOException { MyScanner sc = new MyScanner(); int n = sc.nextInt(); ...
Java
["4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 8", "4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 13"]
1 second
["YES\n4 7 4 7", "NO"]
null
Java 7
standard input
[ "constructive algorithms", "greedy", "brute force" ]
ae5757df3be42b74076cdf42f7f897cd
The first line contains two integers n and m (1 ≤ n, m ≤ 5000) — the size of the array and the number of operations in Levko's records, correspondingly. Next m lines describe the operations, the i-th line describes the i-th operation. The first integer in the i-th line is integer ti (1 ≤ ti ≤ 2) that describes the oper...
1,700
In the first line print "YES" (without the quotes), if the solution exists and "NO" (without the quotes) otherwise. If the solution exists, then on the second line print n integers a1, a2, ... , an (|ai| ≤ 109) — the recovered array.
standard output
PASSED
ef9bc732165f06c65b4709f8bf6a2590
train_001.jsonl
1384102800
Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types: Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j that ...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class c { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner (System.in); PrintWriter out = new PrintWriter (System.out); int n = in.nextInt(); int m = in.nextInt(); i...
Java
["4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 8", "4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 13"]
1 second
["YES\n4 7 4 7", "NO"]
null
Java 7
standard input
[ "constructive algorithms", "greedy", "brute force" ]
ae5757df3be42b74076cdf42f7f897cd
The first line contains two integers n and m (1 ≤ n, m ≤ 5000) — the size of the array and the number of operations in Levko's records, correspondingly. Next m lines describe the operations, the i-th line describes the i-th operation. The first integer in the i-th line is integer ti (1 ≤ ti ≤ 2) that describes the oper...
1,700
In the first line print "YES" (without the quotes), if the solution exists and "NO" (without the quotes) otherwise. If the solution exists, then on the second line print n integers a1, a2, ... , an (|ai| ≤ 109) — the recovered array.
standard output
PASSED
e0f51f44f72e17432f04dec4a866f7ec
train_001.jsonl
1384102800
Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types: Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j that ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Task{ public static void main(String[] args) throws IOException{ new Task().run(); } StreamTokenizer in; Scanner ins; PrintWriter out; int nextInt() throws IOException{ in.nextToken(); ...
Java
["4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 8", "4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 13"]
1 second
["YES\n4 7 4 7", "NO"]
null
Java 7
standard input
[ "constructive algorithms", "greedy", "brute force" ]
ae5757df3be42b74076cdf42f7f897cd
The first line contains two integers n and m (1 ≤ n, m ≤ 5000) — the size of the array and the number of operations in Levko's records, correspondingly. Next m lines describe the operations, the i-th line describes the i-th operation. The first integer in the i-th line is integer ti (1 ≤ ti ≤ 2) that describes the oper...
1,700
In the first line print "YES" (without the quotes), if the solution exists and "NO" (without the quotes) otherwise. If the solution exists, then on the second line print n integers a1, a2, ... , an (|ai| ≤ 109) — the recovered array.
standard output
PASSED
dbdd46f96636d57146c0831de4c0c48f
train_001.jsonl
1384102800
Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types: Increase all elements from li to ri by di. In other words, perform assignments aj = aj + di for all j that ...
256 megabytes
import java.io.BufferedInputStream; import java.io.IOException; import java.io.PrintWriter; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchEx...
Java
["4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 8", "4 5\n1 2 3 1\n2 1 2 8\n2 3 4 7\n1 1 3 3\n2 3 4 13"]
1 second
["YES\n4 7 4 7", "NO"]
null
Java 7
standard input
[ "constructive algorithms", "greedy", "brute force" ]
ae5757df3be42b74076cdf42f7f897cd
The first line contains two integers n and m (1 ≤ n, m ≤ 5000) — the size of the array and the number of operations in Levko's records, correspondingly. Next m lines describe the operations, the i-th line describes the i-th operation. The first integer in the i-th line is integer ti (1 ≤ ti ≤ 2) that describes the oper...
1,700
In the first line print "YES" (without the quotes), if the solution exists and "NO" (without the quotes) otherwise. If the solution exists, then on the second line print n integers a1, a2, ... , an (|ai| ≤ 109) — the recovered array.
standard output
PASSED
35c4484e7f46bb4b445961c30935b9d2
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class VanyaandCards { public static void main(String[] args) { BufferedReader br = new BufferedReader (new InputStreamReader (System.in)); try{ String [] line1 = br.readLine().split("\\s+"); int nCards...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
983acafa71704524ba4553dd5db15f45
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int x=input.nextInt(); int sum=0; while(n-->0) sum+=input.nextInt(); s...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
d8b609cf950248fc59d49098fbabf4c2
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; public class Main { public static boolean debug = false; public stat...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
81db8b41503758c83689a691b0b8d893
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); new A().solve(scanner, out); scanner.close(); out.close(); } } class A { public void...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
163561f9b424c5db45f574166740460b
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Main { public static void m...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
b155824d31be1e7b602de9a3d6b6c90f
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
//если в этой задаче нужно выводить формулу, и оно работает -- я не знаю, как оно работает :) import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Codeforces { private static final int INF = (int) 1e9; BufferedReader in; ...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
d401c5c8f37ffcdb30237796432bfa30
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.*; import java.util.*; import java.*; import java.math.BigInteger; import java.util.ArrayList; import java.util.Random; import java.lang.*; public class zad { private static BufferedReader in; private static StringTokenizer tok; private static PrintWriter out; final static boolean ONLINE_JUDGE =...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
c2a43528bc417270df51143c981c44d5
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.Scanner; public class VanyaAndCards { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int max = in.nextInt(); int sum = 0; for(int i=0; i<n; i++) { sum += in.nextInt(); } if(Mat...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
62f9a0011a133e4d5c34b012f260a18a
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.*; public class VanyaandCards { public static void main (String []args) { Scanner in=new Scanner (System.in); int n=in.nextInt(); int x=in.nextInt(); int rem=0; int res=0; for (int i=0;i<n;i++) rem+=in.nextInt(); while (rem!=0) { ...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
be1c19039fe404e3c3433f730d742da5
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.Scanner; public class VanyaAndCards { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int x = in.nextInt(); long sum = 0; for(int i = 0; i < n; i++){ sum += in.nextInt(); } long ans = 0; sum = sum < 0 ? sum*-1 : sum...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
4bd64353c974e2a69c1438f8e7a7da16
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.LinkedList; import java.util.Scanner; public class Cards { public Cards (){ Scanner stream = new Scanner (System.in); int n = stream.nextInt() ; int x = stream.nextInt(); int [] arr = new int [n]; for (int i =0 ; i < n ; i++){ arr[i] = stream.nextInt() ; } System.out.println(count (ar...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
eaf15c8abe8391b5a6abfdc96c6c41d7
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.Scanner; public class cards { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in=new Scanner(System.in); int n=in.nextInt(); int m=in.nextInt(); int x; int sum=0; for(int i=0;i<n;i++){ x=in.nextInt(); sum+=x; } int a=1; sum=Math.abs(sum)...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
0d957487e6572eeb5f7eab7b1a1aba2b
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class Main { PrintWriter out; BufferedReader input; Main() { try { input = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter(new FileWriter("output.txt"), true); ...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
d1fe771aa89d6d4146cc89add0a042eb
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.*; import java.util.*; public class cards{ public static void main(String args[]) throws IOException { Scanner sc= new Scanner(System.in); int n=Integer.parseInt(sc.next()); int x=Integer.parseInt(sc.next()); int in; int sum=0,f=0,find=0; for(int c=0;c<n;c++) { in=Integer.parseInt(sc.next()); sum+=i...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
87b60827e929787f0b9986a03acc5a0d
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.*; public class a401 { public static void main(String ar[]) { Scanner ob=new Scanner(System.in); int n=ob.nextInt(); int m=ob.nextInt(); int x=0,sum=0; for(int i=0;i<n;i++) { sum=sum+ob.nextInt(); } sum=Math.abs(sum); if(sum>=m) { if(sum%m==0) System.out.println(sum/m); ...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
b33bb6861c74836c68ee2a36d4b9ae96
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.*; public class Cards { public static void main(String[] args) { Scanner input = new Scanner(System.in); int numCards = input.nextInt(); int maxVal = input.nextInt(); int startVal = 0; for (int i = 0; i < numCards; i++) { startVal += input.nextInt(); } int cardsNe...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
a194f5fe3f1f0aca2111430f837c4722
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class A401 { public static void main(String args[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int x = in.nextInt(); ArrayList<Integer> cards = new ArrayList<>(); int sum=0; for (int i=0 ...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
b0a98a1ec5dfe92ac8fe158b7e945dea
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.Scanner; public class VanyAndCards { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int x = input.nextInt(); input.nextLine(); int sum = 0; int result = 0; for (int i = 0; i < n; i...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
ec103c00aacad85f76745936b3abeb3b
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner inScanner = new Scanner(System.in); int n = inScanner.nextInt(); int x = inScanner.nextInt(); double sum = 0; for (int i = 0; i < n; i++) { sum += inScanner.nextInt(); } System.out.println((...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
ce521ec62592455b1147dd0c44781a59
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class Solution implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); public static void main(St...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
d0cd19136b755b5d4c1f28c4516980a4
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class CombinationLock { static class Reader { BufferedReader r; StringTokenizer str; ...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
5220102b2aff911d60cc702d90f8e214
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Set; import java.util.StringTo...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
a59ff200051a2e0518cd2722fb3ec509
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class VanyaandCards { public static void main(String[] args) throws IOException{ BufferedReader in= new BufferedReader(new InputStreamReader(System.in)); StringToke...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
3f7d75c826ac133f8f69004f9af7c750
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.lang.*; import java.util.Scanner; public class vanya_and_cards { public static void main(String args[]) { int n,x; Scanner s=new Scanner(System.in); n=s.nextInt(); x=s.nextInt(); int i,input,count=0; int sum=0; for(i=0;i<n;i++) { input=s.nextInt(); sum+=input; } if(sum<0) s...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
f7bacd075807498755a86fc4e68fd2f1
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static void main (String [] args) throws...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
f63a43db71be340d4ddcbf27d5e5c931
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
//package javaapplication1; import java.io.*; import java.util.*; public class JavaApplication1 implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); final boolean OJ = System.getProperty("ONLINE_JUDGE") != null; void init() throws FileNotFoun...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
215f82b893e813e8339caa4e15775611
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int x=sc.nextInt(); int sum=0; for(int i=0;i<n;i++) sum+=sc.nextInt(); int t=0; if(sum<0) ...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
51939e360a822066d6ab6d847ef4ec08
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; import static java.lang.Math.abs; /** * Created by Dmytry on 3/10/14. */ public class Main { static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st = new ...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
a96f032c025e03d9390cc65becd12d9d
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.*; public class Cards { public static void main(String[]args) { Scanner sc=new Scanner(System.in); int found=sc.nextInt(); int maxNum=sc.nextInt(); int sumFound=0; int j=1; int needed=0; do { sumFound+=sc.nextInt(); j++; } while(j<=found); if (sumFound>0) maxNum=-maxNum; ...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
20d8ad3135fdc5fa3805d0c657b735d1
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Round235 { //problem A public static void main(String[] arg) throws IOException{ BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String[] line = bf.readLine().split(" "); int li...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
ae9b2f6859a3ec1865956c8c676c0fda
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.Scanner; public class TaskA { static Scanner scn = new Scanner(System.in); public static void main(String[] argc) { int n, x, sum = 0; int a, ans; n = scn.nextInt(); x = scn.nextInt(); for (int i = 0; i < n; i++) { a = s...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
88866d81083803e3edce78ec6c0fe647
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.Scanner; /** * Created by Oleksiy on 10.03.14. */ public class A { public static void main(String[] args) { int n,x; int sum = 0; Scanner sf = new Scanner(System.in); n = sf.nextInt(); x = sf.nextInt(); for (int i=0; i<n; i++) { sum += ...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
f93c2d96ee240d7186aa4d58378d0e41
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.InputMismatchException; /** * * @author jigsaw */ public class Main { /** * @param args...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
b8efbdf8a56b06b55ce659008e6ae701
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class test { static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer ...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
ac442b3b3462c42bb369e7204e3521e0
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @auth...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
e89f4f666abd7daabca3fe3eca8ea915
train_001.jsonl
1394465400
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.Natasha doesn't like when Vanya spends a long time playi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Task401A { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new Str...
Java
["3 2\n-1 1 2", "2 3\n-2 -2"]
1 second
["1", "2"]
NoteIn the first sample, Vanya needs to find a single card with number -2.In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.
Java 7
standard input
[ "implementation", "math" ]
066906ee58af5163636dac9334619ea7
The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.
800
Print a single number — the answer to the problem.
standard output
PASSED
5f39c3ee195591d3ad104899d4828d1c
train_001.jsonl
1585233300
You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is alr...
256 megabytes
import java.util.Scanner; public class divisible { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int cases = in.nextInt(); in.nextLine(); for(int t = 0; t < cases ; t++) { int a = in.nextInt(); int b = in.nextInt(); int count = ...
Java
["5\n10 4\n13 9\n100 13\n123 456\n92 46"]
1 second
["2\n5\n4\n333\n0"]
null
Java 11
standard input
[ "math" ]
d9fd10700cb122b148202a664e7f7689
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
800
For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.
standard output
PASSED
d15c5fe7bc9588bed434aece499f61d9
train_001.jsonl
1585233300
You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is alr...
256 megabytes
import java.util.Scanner; public class CFP1328A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int i = 0; i < t; i++) { int a = in.nextInt(); int b = in.nextInt(); int x = 0; if(a % b...
Java
["5\n10 4\n13 9\n100 13\n123 456\n92 46"]
1 second
["2\n5\n4\n333\n0"]
null
Java 11
standard input
[ "math" ]
d9fd10700cb122b148202a664e7f7689
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
800
For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.
standard output
PASSED
e9303005c2ac1fc81fc029b643e3a0a7
train_001.jsonl
1585233300
You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is alr...
256 megabytes
import java.util.Scanner; public class main { public static void main(String[] args) { Scanner test = new Scanner(System.in); int x = test.nextInt(); for(int y = 0; y < x;y++) { int a = test.nextInt(); int b = test.nextInt(...
Java
["5\n10 4\n13 9\n100 13\n123 456\n92 46"]
1 second
["2\n5\n4\n333\n0"]
null
Java 11
standard input
[ "math" ]
d9fd10700cb122b148202a664e7f7689
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
800
For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.
standard output
PASSED
4cf547e293cc92751bb69e0b0e2599c0
train_001.jsonl
1585233300
You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is alr...
256 megabytes
import java.util.Scanner; public class Divisibility { public static void main(String[] args) { 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(); if(a % b == 0) System.out.println("0"); else System.out.println(b - ...
Java
["5\n10 4\n13 9\n100 13\n123 456\n92 46"]
1 second
["2\n5\n4\n333\n0"]
null
Java 11
standard input
[ "math" ]
d9fd10700cb122b148202a664e7f7689
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
800
For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.
standard output
PASSED
e8db0d536e426c09cd557cfaaf7bce67
train_001.jsonl
1585233300
You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is alr...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static int findMoves(double a, double b) { if (a <= b) return (int)(b - a); int i = (int)Math.ceil(a / b); return (int)((b * i) - a); } public static void main(String [] args) { Scanner in = new Scan...
Java
["5\n10 4\n13 9\n100 13\n123 456\n92 46"]
1 second
["2\n5\n4\n333\n0"]
null
Java 11
standard input
[ "math" ]
d9fd10700cb122b148202a664e7f7689
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
800
For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.
standard output
PASSED
12073186bd3b93cb0b3819f6b8e2e645
train_001.jsonl
1585233300
You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is alr...
256 megabytes
import java.util.Scanner; public class Solution{ public static void main(String[] args){ Scanner s = new Scanner(System.in); int loop = s.nextInt(); for(int i = 0; i < loop; i++){ int a = s.nextInt(); int b = s.nextInt(); if(a%b == 0){ Syst...
Java
["5\n10 4\n13 9\n100 13\n123 456\n92 46"]
1 second
["2\n5\n4\n333\n0"]
null
Java 11
standard input
[ "math" ]
d9fd10700cb122b148202a664e7f7689
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
800
For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.
standard output
PASSED
7622a66a7bb44eaaf81b244fe68a1037
train_001.jsonl
1585233300
You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is alr...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); long t = scanner.nextLong(); for (int i = 0; i < t; i++) { long a = scanner.nextLong(); long b = scanner.nextLong(); System.out.p...
Java
["5\n10 4\n13 9\n100 13\n123 456\n92 46"]
1 second
["2\n5\n4\n333\n0"]
null
Java 11
standard input
[ "math" ]
d9fd10700cb122b148202a664e7f7689
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
800
For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.
standard output
PASSED
2c447ba3c8a706f678e9e4e2acb35c96
train_001.jsonl
1585233300
You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is alr...
256 megabytes
import java.util.Scanner; public class DivisibilityProblem1328A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); //TODO optimalize execution time (<1000ms); int n = Integer.parseInt(sc.nextLine()); for (int i = 0; i < n ; i++) { Stri...
Java
["5\n10 4\n13 9\n100 13\n123 456\n92 46"]
1 second
["2\n5\n4\n333\n0"]
null
Java 11
standard input
[ "math" ]
d9fd10700cb122b148202a664e7f7689
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
800
For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.
standard output
PASSED
b8b5f463e86f4a329259a7598b18db2b
train_001.jsonl
1585233300
You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is alr...
256 megabytes
import java.util.*; public class Divisibility { public static void main (String[] args) { Scanner scan = new Scanner (System.in); int cases = scan.nextInt(); for (int i = 0; i < cases; i++) { int a = scan.nextInt(); int b = scan.nextInt(); ...
Java
["5\n10 4\n13 9\n100 13\n123 456\n92 46"]
1 second
["2\n5\n4\n333\n0"]
null
Java 11
standard input
[ "math" ]
d9fd10700cb122b148202a664e7f7689
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
800
For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.
standard output
PASSED
b3528eccb048820445b7f2a345a9d6a7
train_001.jsonl
1585233300
You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is alr...
256 megabytes
// Working program with FastReader import java.io.*; import java.util.StringTokenizer; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in...
Java
["5\n10 4\n13 9\n100 13\n123 456\n92 46"]
1 second
["2\n5\n4\n333\n0"]
null
Java 11
standard input
[ "math" ]
d9fd10700cb122b148202a664e7f7689
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
800
For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.
standard output
PASSED
59679fb6feec2aa4264fa63b05c62e58
train_001.jsonl
1585233300
You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is alr...
256 megabytes
import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Solution { // Complete the hourglassSum function below. static int[] result(int[][] arr, int t) { int[] result = new int[t]; ...
Java
["5\n10 4\n13 9\n100 13\n123 456\n92 46"]
1 second
["2\n5\n4\n333\n0"]
null
Java 11
standard input
[ "math" ]
d9fd10700cb122b148202a664e7f7689
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).
800
For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.
standard output
PASSED
dd757735cbbb0dd9cfc1d0e955a01097
train_001.jsonl
1570374300
You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something!You have $$$n$$$ tickets to sell. The price of the $$$i$$$-th ticket is $$$p_i$$$. As a teller, you have a possibility to select the order in which the tickets will be sold (i.e. a ...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(output...
Java
["4\n1\n100\n50 1\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n10 2\n15 3\n107\n3\n1000000000 1000000000 1000000000\n50 1\n50 1\n3000000000\n5\n200 100 100 100 100\n69 5\n31 2\n90"]
2 seconds
["-1\n6\n3\n4"]
NoteIn the first query the total contribution is equal to $$$50 + 49 = 99 &lt; 100$$$, so it's impossible to gather enough money.In the second query you can rearrange tickets in a following way: $$$[100, 100, 200, 200, 100, 200, 100, 100]$$$ and the total contribution from the first $$$6$$$ tickets is equal to $$$100 \...
Java 11
standard input
[ "data structures", "binary search", "greedy" ]
4835d79ad6055a7c9eb5d4566befeafc
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 100$$$) — the number of independent queries. Each query consists of $$$5$$$ lines. The first line of each query contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of tickets. The second line contains $$$n$$$ integers $$$p_1, p...
1,600
Print $$$q$$$ integers — one per query. For each query, print the minimum number of tickets you need to sell to make the total ecological contribution of at least $$$k$$$ if you can sell tickets in any order. If the total contribution can not be achieved selling all the tickets, print $$$-1$$$.
standard output
PASSED
fa19301a17c5ac0e4d452d98b1b15aaa
train_001.jsonl
1570374300
You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something!You have $$$n$$$ tickets to sell. The price of the $$$i$$$-th ticket is $$$p_i$$$. As a teller, you have a possibility to select the order in which the tickets will be sold (i.e. a ...
256 megabytes
import java.io.*; import java.util.*; public class Main { private void solve()throws IOException { int n=nextInt(); int p[]=new int[n+1]; for(int i=1;i<=n;i++) p[i]=nextInt()/100; Arrays.sort(p,1,n+1); long sum[]=new long[n+1]; for(int i=1;i<=n;i++) sum[i]=sum[i-1]+p[i]; int x=nextInt(); int a...
Java
["4\n1\n100\n50 1\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n10 2\n15 3\n107\n3\n1000000000 1000000000 1000000000\n50 1\n50 1\n3000000000\n5\n200 100 100 100 100\n69 5\n31 2\n90"]
2 seconds
["-1\n6\n3\n4"]
NoteIn the first query the total contribution is equal to $$$50 + 49 = 99 &lt; 100$$$, so it's impossible to gather enough money.In the second query you can rearrange tickets in a following way: $$$[100, 100, 200, 200, 100, 200, 100, 100]$$$ and the total contribution from the first $$$6$$$ tickets is equal to $$$100 \...
Java 11
standard input
[ "data structures", "binary search", "greedy" ]
4835d79ad6055a7c9eb5d4566befeafc
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 100$$$) — the number of independent queries. Each query consists of $$$5$$$ lines. The first line of each query contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of tickets. The second line contains $$$n$$$ integers $$$p_1, p...
1,600
Print $$$q$$$ integers — one per query. For each query, print the minimum number of tickets you need to sell to make the total ecological contribution of at least $$$k$$$ if you can sell tickets in any order. If the total contribution can not be achieved selling all the tickets, print $$$-1$$$.
standard output
PASSED
f849854982bdffdc0a8b6e928b0506b4
train_001.jsonl
1570374300
You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something!You have $$$n$$$ tickets to sell. The price of the $$$i$$$-th ticket is $$$p_i$$$. As a teller, you have a possibility to select the order in which the tickets will be sold (i.e. a ...
256 megabytes
import java.util.*; import java.io.*; public class C591 { public static void main(String[] args) { MyScanner sc = new MyScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int q = sc.nextInt(); while (q-- > 0) { int n = sc.nextInt(); ...
Java
["4\n1\n100\n50 1\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n10 2\n15 3\n107\n3\n1000000000 1000000000 1000000000\n50 1\n50 1\n3000000000\n5\n200 100 100 100 100\n69 5\n31 2\n90"]
2 seconds
["-1\n6\n3\n4"]
NoteIn the first query the total contribution is equal to $$$50 + 49 = 99 &lt; 100$$$, so it's impossible to gather enough money.In the second query you can rearrange tickets in a following way: $$$[100, 100, 200, 200, 100, 200, 100, 100]$$$ and the total contribution from the first $$$6$$$ tickets is equal to $$$100 \...
Java 11
standard input
[ "data structures", "binary search", "greedy" ]
4835d79ad6055a7c9eb5d4566befeafc
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 100$$$) — the number of independent queries. Each query consists of $$$5$$$ lines. The first line of each query contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of tickets. The second line contains $$$n$$$ integers $$$p_1, p...
1,600
Print $$$q$$$ integers — one per query. For each query, print the minimum number of tickets you need to sell to make the total ecological contribution of at least $$$k$$$ if you can sell tickets in any order. If the total contribution can not be achieved selling all the tickets, print $$$-1$$$.
standard output
PASSED
e24cbbb79e2f04308f81703c2cd8e22b
train_001.jsonl
1570374300
You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something!You have $$$n$$$ tickets to sell. The price of the $$$i$$$-th ticket is $$$p_i$$$. As a teller, you have a possibility to select the order in which the tickets will be sold (i.e. a ...
256 megabytes
import java.util.*; import java.io.*; public class C591 { public static void main(String[] args) { MyScanner sc = new MyScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int q = sc.nextInt(); while (q-- > 0) { int n = sc.nextInt(); ...
Java
["4\n1\n100\n50 1\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n10 2\n15 3\n107\n3\n1000000000 1000000000 1000000000\n50 1\n50 1\n3000000000\n5\n200 100 100 100 100\n69 5\n31 2\n90"]
2 seconds
["-1\n6\n3\n4"]
NoteIn the first query the total contribution is equal to $$$50 + 49 = 99 &lt; 100$$$, so it's impossible to gather enough money.In the second query you can rearrange tickets in a following way: $$$[100, 100, 200, 200, 100, 200, 100, 100]$$$ and the total contribution from the first $$$6$$$ tickets is equal to $$$100 \...
Java 11
standard input
[ "data structures", "binary search", "greedy" ]
4835d79ad6055a7c9eb5d4566befeafc
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 100$$$) — the number of independent queries. Each query consists of $$$5$$$ lines. The first line of each query contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of tickets. The second line contains $$$n$$$ integers $$$p_1, p...
1,600
Print $$$q$$$ integers — one per query. For each query, print the minimum number of tickets you need to sell to make the total ecological contribution of at least $$$k$$$ if you can sell tickets in any order. If the total contribution can not be achieved selling all the tickets, print $$$-1$$$.
standard output
PASSED
d3dea637ff6919f333493e048e929c4e
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; public class JavaApplication11 { public static long max = 1; public static void main(String[] args) { Scanner io = new Scanner(System.in); int t = io.nextInt(); while(t-- != 0) { int n = io.nextInt(), s = io.nextInt(), k = io.nextInt(); int min...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
479dc24978a9359fd2da0e555962579b
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; public class test { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); int tests = Integer.parseInt(bufferedReader.readLine().trim()); for (int i =0; i < t...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
3b9af5e8ef2be19103106123b22f3e53
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; import java.math.BigInteger; public class Main { String filename = "";//filename here, System.in/out if no file FastScanner in; PrintWriter out; void solve() { int t = in.nextInt(); int n = 0; int s = 0; int k = 0; for (i...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
59f7196e072d320f337718f9dd634090
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; /** * * @author Saju * */ public class Main { private static int dx[] = { 1, 0, -1, 0}; private static int dy[] = { 0, -1, 0, 1}; private static final long INF = (long) (1e15); private static final int INT_INF = Integer.MAX_VALUE; private static fin...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
e842661c0ddaeff75f74b3284a12b0e8
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; /** * * @author Saju * */ public class Main { private static int dx[] = { -2, -3, -2, -1, -1, 1}; private static int dy[] = { 1, -1, -1, -2, -3, -2}; private static final long INF = (long) (1e15); private static final long NEG_INF = Long.MIN_VALUE; ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
83ff9b5dea1dd8bbc53e18474379efff
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner (System.in); int t=sc.nextInt(); for(int i=0;i<t;i++) { int n=sc.nextInt(); int s=sc.nextInt(); int k=sc.nextInt(); int []a=new int [k+5]; for(...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
dd1f3247d9f8e1eb9b2fa18fc790e31d
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; public class A1293 { public static int runn(int a,int b, int[] mang, int k, int n) { int u=0; int r=0; for(int i=0; i<k; i++) { if((a==mang[i] && a<=n)|| a>n) { u=1; } if((b==mang[i]&& b>0)|| b<=0) { r=1; } if((u==1 && r==1)) { return 0; } } return 1; }...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
b6e0066e9ebde0e70433bcbaa1ec7c1e
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { static int ar[]; static int di[]; static LinkedList<Integer> al[]; static int ll[]; static boolean p[]; static int v; static long mod=1000000007l; static HashSet<Integer> h=new HashSet<>(); static int max=Integer.MAX_VALUE,min=Int...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
857fdcf2a11cb9892940a951b97bed70
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class cf8 { static long mod = (long) Math.pow(10, 9) + 7; static FastScanner f = new FastScanner(System.in); static Scanner S = new Scanner(System.in); public static void main(String[] args) { int t = f.nextInt(); ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
64435f6b3af391c276c2aeb157d83b45
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; public class CodeForcesMain { private void code() throws IOException { int times = readlineInt(); for (int t = 0; t < times; t++) { readlineInts(); int n = intLinesTmp[...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
a1a816ee4ee2d14a3ba9068ffebfe620
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; public class CodeForcesMain { private void code() throws IOException { int times = readlineInt(); for (int t = 0; t < times; t++) { readlineInts(); int n = intLinesTmp[...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
1720d765d684acb934f065ff5c2178a2
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; public class Q1 { public static void main(String[] args) { InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out); int t =in.nextInt(); while(t-->0) { int n = in.nextInt(),s=in.nextInt(),k=in.nextInt...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
7af883723bc5991d9235a9e084a66109
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; public class cf1293a { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); T: for (int tc = 0; tc < t; tc++) { int n = in.nextInt(); int s = in.nextInt(); int k = in.nextInt(...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
049186000dd28973b062d23517d3a956
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class connerAndTheArcMarkland { public static void main(String args[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(); for(int i = 0; i<n; i++) { int f = in.nextInt(); int s = in.nextInt(); int k= in.nextInt(); int[] arr = new in...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
a2620a98a0f6296d79b437de0bef55b4
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; public class MyClass { 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) ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
59a455fe069e2d651be56e7aa68a06d1
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; public class MyClass { 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) ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
a43154204fffc092ffbb2ed7ed573770
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.awt.*; import java.nio.file.Paths; import java.util.*; import java.io.*; public class TaskE { //================================================ //Константы....................................... //================================================ static final long N = (long) (1e5 + 10); ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
5b7adcc583f9cae1bf7bb0cfc93bb03b
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashSet; import java.util.StringTokenizer; import java.util.TreeSet; public class k {...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
62626fbfca902a0014dddfdeaef377bd
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; public class Codeforce { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- != 0){ int n = sc.nextInt(), s = sc.nextInt(), k = sc.nextInt(); ArrayList<Integer> lst = new ArrayLis...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
f2c7580767afe807f8a16eda29e10895
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; public class Codeforce { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- != 0) { int n = sc.nextInt(); int s = sc.nextInt(); int k = sc.nextInt(); HashSet<Int...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
8f84e27e2fd821cf3625d65f1e272f29
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.HashSet; import java.util.Scanner; public class conner { // static class FastReader // { // BufferedReader br; // StringTokenizer st; // // public FastReader() // { // br = new BufferedReader(new // InputStreamReader(System.in));...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
9231967bb24e463d8e4f0c147d6f5eb1
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class A { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for (int i = 0; i < t; i++) { int n = scanner.nextInt(); int s = ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
fc24a48745849cfe923adfee1258c700
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; import java.text.DecimalFormat; import java.io.*; public class FedorNewGame { public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine().trim()); wh...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
bfc91ed2368c1d2f16b783f4695f2fe4
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class Main{ public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output