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
41cb664b60faea239e8c5502e24035bc
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; public class A167 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n= sc.nextInt(); int arr[] = new int[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); } int s = sc.nextInt(); int t= sc.nextInt(); int a=0,b=0; int x= (s<=t?s-...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
26376d4a876fe3e28bdeb62ea8806524
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
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
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
725ab64219606d91ae118ae7351d3afd
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class r2 { public static void main(String[] args) { Scanner cin=new Scanner(System.in); while(cin.hasNext()){ int n=cin.nextInt(); int[] num=new int[n+5]; int sum=0; for(int i=1;i<=n;i++){ ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
555a0b7dd25c4725a78eba796cc9b20f
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main (String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] circle = new int[n]; int idx = 0; while (n > 0) { n--; circle[idx] = in....
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
3a7ac0c43e3df8eada649b6ad4f56da7
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
/* * @Author: steve * @Date: 2015-10-08 15:04:28 * @Last Modified by: steve * @Last Modified time: 2015-10-08 15:12:35 */ import java.io.*; import java.util.*; public class CircleLine { public static void main(String[] args) throws Exception{ BufferedReader entrada = new BufferedReader(new InputStreamRea...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
63d3f436931e3d085b18b2575574365c
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ //package prob2; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author Rania */ public class Prob2 { /** * @param args the command line arguments ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
fb135f10df65caa2fa0a396060f3da59
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.*; public class Main{ public static void main(String[]args){ Scanner cin=new Scanner(System.in); for(int n,m,S[]=new int[101];cin.hasNextInt();System.out.println(Math.min(m,S[n]-m))){ for(n=cin.nextInt(),m=0;n>m++;S[m]=cin.nextInt()+S[m-1]); m=cin.nextInt()-1;m=Math.abs(S[cin.nextInt()-1]-S[...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
ca03430a35c13635b883e525bf065311
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.*; public class Main{ public static void main(String[]args){ Scanner cin=new Scanner(System.in); int n=cin.nextInt(),m=0,S[]=new int[1+n]; for(;n>m++;S[m]=cin.nextInt()+S[m-1]); m=Math.abs(S[cin.nextInt()-1]-S[cin.nextInt()-1]); System.out.print(Math.min(m,S[n]-m)); } }
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
3855678f5a25665a0f1a4cad19a0ee09
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class AA { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader rd = new...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
ad12c16386b2a791774667ec4ccd705b
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; public class CircleLine278A { public static void main(String[] args) { @SuppressWarnings("resource") Scanner sc = new Scanner(System.in); int n = sc.nextInt(), totalDistance = 0; int[] arr = new int[n]; for(int i=0;i<n;i++){ ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
9760842c22b1ec498e92c17b2b5a613c
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.lang.*; import java.io.*; import java.util.*; public class Line { public static void main(String[] args) throws java.lang.Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(out...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
3c5e818b7d5116940a2633bf8d36ba87
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.*; import java.io.InputStream; /** * Created by G.Gekko. */ public class Solution { public static void main(String[] args) throws IOException { ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
decce964c6bdcca0d0be096d6ebeb702
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.io.*; import java.util.*; public class CF170A { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); StringTokenizer stringTokenizer; String next() throws IOException{ while(stringTokenizer == null || !stringTokenizer.has...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
171f354eb6b4a7f38813e0f81984f155
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; public class ShortestDistance { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[]d=new int[n+1]; for(int i=1;i<n+1;i++) { d[i]=sc.nextInt(); } int s...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
d35beed1b287a6dee90a904664b9c250
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; public class ShortestDistance { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[]d=new int[n+1]; for(int i=1;i<n+1;i++) { d[i]=sc.nextInt(); } int s=s...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
e462fb67280ca8ea5ca996013fde9dcc
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int s[] = new int[n]; int sum = 0; for (int i = 0; i < n; i++) { s[i] = sc.nextInt(); sum += s[i]; ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
1758552294bdda2e92b1bfbc4eef7618
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.*; public class CircleLine { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] distances = new int[n]; int total = 0; for (int i = 0; i < n; i++) { distances[i] = in.nextInt(); t...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
e056d9157c75b6873274ed6069797ec0
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class CF0278A { public static void main(String[] helloWorld) throws IOException { BufferedReader sIn = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(sIn.readLine()); int[] pos = new int[n + 1]; int total = 0; StringT...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
4f8b790bbef8eff8e73c85bcfc6dd84c
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; /** * * @author Izhari Ishak Aksa */ public class CircleLine { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] d = new int[n]; for (int i = 0; i < n; i++) { d[i] = sc.nextInt(); ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
db68ed0d05c73911865e4d158368c4e1
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int d[] = new int[n]; for (int i = 0; i < n; i++) { d[i] = sc.nextInt(); } int s = sc.nextInt() - 1; int...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
c25339062e5a9224b2786ee539a4322e
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner kb = new Scanner(System.in); int n=kb.nextInt(); int[] dis=new int[n]; for(int i=0;i<n;i++){ dis[i]=kb.nextInt(); } int s=kb.nextInt();...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
049f75415aff4931c74e5ae1f3d781be
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.*; import java.io.IOException; public class metro { public static void main (String[] args) throws IOException { Scanner in = new Scanner(System.in); int summ1=0, summ2=0; int stan = in.nextInt(); int array[] =new int [stan]; for (int i = 0; i < stan; i++) { ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
48a7da1aac233d396c0d638385de6285
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import org.omg.DynamicAny._DynArrayStub; import java.lang.reflect.Array; import java.util.*; /** * Created by root on 7/14/14. */ public class test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] distances = new int[n]; ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
7b5c1c53d6b46cc707292592a7013e81
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; /** * The circle line of the Berland subway has n stations. We know the distances * between all pairs of neighboring stations: * * d1 is the distance between the 1-st and the 2-nd station; d2 is the distance * between the 2-nd and the 3-rd station; ... * * dn - 1 is the distance betw...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
85a632c32769a4ae79d3a88631d4bb30
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; public class Dist { public static void main(String ar[]){ Scanner sb=new Scanner(System.in); String s=sb.nextLine(); int n=Integer.parseInt(s); String b=sb.nextLine(); String a[]=b.split(" "); int d[]=new int[n]; for(int i=0;i<n;i++) { d[i]=Integer.parseInt(a[i]); } String e=sb.nextLine(); Str...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
5e561cb34eeebf360c01c94fa4b2bd4d
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; public class CircleLine{ public static void main(String args[]) { int n, s, t; int[] array = new int[100]; Scanner sc = new Scanner(System.in); n = sc.nextInt(); for(int i=0;i<n;i++) { array[i] = sc.nextInt(); } ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
31aaccb9e23b8f3f93395df232e883ef
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.*; public class CF278A_CircleLine { public static void main(String[] args){ Scanner in=new Scanner(System.in); int n=in.nextInt(); int[] a=new int[n]; for(int i=0;i<n;i++){ a[i]=in.nextInt(); } int s=in.nextInt()-1; int f=in.nextInt()-1; if(s>...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
fd62a8e1f866a5b9f89a3dd3aec7900b
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import static java.lang.Math.*; public class Maain implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
69a23c111f58e98d3b199633e5117685
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // write your code here Scanner scan = new Scanner(System.in); int stationCount = scan.nextInt(); int[] lenghtBetwStations = new int[102]; for (int i=1;i<=stationCount;i++){ lengh...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
523ba94a675dcdd9c842956ca82bc2b5
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.Scanner; public class dis { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n]; sc.nextLine(); for(int i=0;i<n;i++) { a[i]=sc.nextInt(); } sc.nextLine(); int x=sc.nextInt(),y=sc.nextInt(); if(x>y) { int t=x; x=y; ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
3fc05a26470ed58f41f902c02e1ebd8e
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.*; public class Main { public static void main (String args[]){ Scanner input= new Scanner(System.in); int n= input.nextInt(); int a[]= new int[n+1]; int i; for(i=1;i<=n;i++) a[i]=a[i-1]+input.nextInt(); int temp1=input.nextInt(); int temp2=input.nextInt(); int max= Math.max(temp1, temp2); int min...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
d650b9fbbdd2c15eb463096016040594
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.util.*; public class DisplayTime{ public static void main(String[] arg) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int dis[] = new int[n]; for (int i = 0; i < n; ++i) { dis[i] = input.nextInt(); } int s = input.nextInt(), t = input.nextInt(); input.close(); in...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
11127c00de5496ca4b3af3288a15f95d
train_001.jsonl
1362065400
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations: d1 is the distance between the 1-st and the 2-nd station; d2 is the distance between the 2-nd and the 3-rd station;... dn - 1 is the distance between the n - 1-th and the n-th station; dn is the distan...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; 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 class Main { public static ...
Java
["4\n2 3 4 9\n1 3", "4\n5 8 2 100\n4 1", "3\n1 1 1\n3 1", "3\n31 41 59\n1 1"]
2 seconds
["5", "15", "1", "0"]
NoteIn the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.In the fourth sample the numbers of stat...
Java 7
standard input
[ "implementation" ]
22ef37041ebbd8266f62ab932f188b31
The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers s and t (1 ≤ s, t ≤ n) — the numbers of stations, between which you ...
800
Print a single number — the length of the shortest path between stations number s and t.
standard output
PASSED
c686ab2adc38117657cb39f6ff4e3c4d
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.Scanner; public class qq4 { public static void main(String[] args) { Scanner a = new Scanner(System.in); int t = a.nextInt(); int[] digits = new int[19]; int[] presum = new int[19]; for(int i = 0; i < t; i++) { for(int k = 0; k < 19; k++) { digits[k] = presum[k] = 0; } long n...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
842c340d799c61139620a6ef88fbdc43
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
2555840a3f4e4f58ed41943dc98254bd
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.InputStream; import java.io.BufferedReader; import java.io.PrintWriter; import java.io.InputStreamReader; import java.io.IOException; import java.util.*; public class SumDigit { public static void main(String[] args) throws IOException { InputReader in = new InputReader(System.in); PrintWriter...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
9ddd5bded2cc67cf267de75d5707d08d
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.*; import java.io.*; public class Solution{ static int sumdig(long n) { int ans=0; while(n!=0) { ans=ans+(int)(n%10); n=n/10; } return ans; } public static void main(String args[])throws IOException { BufferedRe...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
027f4e4b125469735343040c64c389ef
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.*; import java.util.*; public class D { public static void main(String[] args) throws IOException { FastReader f=new FastReader(); StringBuffer sb=new StringBuffer(); int test=f.nextInt(); while(test-->0) { long n=f.nextLong(); int s=f.nextInt(); long ans=0; if(sum(n)<...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
59d1d25ae03783ba9e107c554b4df40b
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.Scanner; public class NewClass4 { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); w: while (t-- > 0) { long n = scan.nextLong(); int s = scan.nextInt(); String k = String....
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
f1d7eb077270cf189c89d81642e0363f
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.Scanner; public class DecreasetheSumofDigits { static long sumOfDigit(long n) { String s = String.valueOf(n); long sum = 0; for (int i = 0; i < s.length(); i++) { sum += s.charAt(i) - '0'; } return sum; } static long rec(long n, long s...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
937a30d1444a35032a4ab6c4912dbfa0
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.*; import java.util.Scanner; import java.io.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import javax.lang.model.util.ElementScanner6; public class D1409 { public static void main(...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
a89d61ea2e6b8e2fe4d66244593b686e
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
/*****Author: Satyajeet Singh************************************/ import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.*; public class Main{ /*********************************************Constants******************************************/ static Print...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
a73916822de95a573b87038914b260d2
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
//package ru.ilinchik.codeforces; import java.util.Scanner; /** * https://codeforces.com/contest/1409/problem/D */ public class D667 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int i = 0; i < t; i++) { long n = i...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
f25fda13d31aa772972c35a890dab820
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; import java.math.BigInteger; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { In...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
9098bcc0a59b523cd914e7629a5b4376
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.*; import java.util.*; public class WhatIsThisBro { private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); private static StringTokenizer st...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
70fef2d22611382a81774987756ae2a2
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
// package CodeForces; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; public class Round667D { public static void solve() { int t = s.nextInt(); long[] pow10 = new long[20]; pow10[0] = 1; for(i...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
2e838510b2401fc0e8b188f2c66481d5
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.*; import java.util.*; public class Main { static final long MOD = 1000000007L; static final int INF = 50000000; static final int NINF = -50000000; public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter pw = new PrintWriter(System.out)...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
7dc5fa8c6f7de5cd88b1ba30985e5821
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.*; import java.io.*; import java.text.*; /** * * @author alanl */ public class Main{ static BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
21e9cef27ae74301d7b481b86322635c
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class D { public static void main(String hi[]) throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(infile.readLine()); int ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
008ecd13365ada9746af214358d60f78
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.*; import java.io.*; public class _1409D { static int[] MODS = {1000000007, 998244353}; static int MOD = MODS[0]; public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int t = sc.nextIn...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
d1c69935d67e458374c85437834cf7d2
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Lin...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
47ada2bc8e1344f0d92f152bd36323fe
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.*; public class Tester { public static void main(String[] args){ Scanner input = new Scanner(System.in); int t = input.nextInt(); for(int testCase = 1; testCase <= t; testCase++){ long n = Long.valueOf(input.next()); long s = Long.valueOf(input.next(...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
9719af0787fc3a248643bc46075ce2f3
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.*; public class D { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for (int tt = 1; tt <= T; tt++) { String n = "0" + sc.next(), tmp = n; int s = sc.nextInt(); while(sum(n) > s) { ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
6a2cdad1275161f0e5723cb8cf406576
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.*; public class D { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for (int tt = 1; tt <= T; tt++) { String n = sc.next(), tmp = n; int s = sc.nextInt(); while(sum(n) > s) { ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
4c24cc9040ac0ba09c50cf291d22e2bb
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.*; import java.util.*; public class DecreasetheSumofDigits { static int countDigits(long n) { int ans = 0; while(n!=0) { n/=10; ans++; } return ans; } static int sumod(int a[],int j) { int sum = 0; for(int i=0;i<=j;i++) sum+=a[i]; return sum; } static void putZero(int a[...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
e7c853c0d0a395cad5ff64b5add754a6
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.math.BigInteger; public final class codeForces { public static void main(String args[]) { StringBuilder ans=new StringBuilder();; FastReader in=new FastReader(); int T=in.nextInt(); while(T-->0) ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
013e1c8752c25cf6136b8be2e4c09e39
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class D { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
a12cd60151114467b64babedca28b7db
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
//package CodeForces; import java.io.*; import java.util.*; public class Main { public class Haha { /* _____ ___ /\ /\ | | | | /\ /\ /\ /\ /\ /\ | \ محمد أ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
5218c9468e237da131664d566d53a4a6
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
//package CodeForces; import java.io.*; import java.util.*; public class Main { public class Haha { /* _____ ___ /\ /\ | | | | /\ /\ /\ /\ /\ /\ | \ محمد أ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
bf7cbd5e363083eaef80add4c486edcb
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
//package CodeForces; import java.io.*; import java.util.*; public class Main { public class Haha { /* _____ ___ /\ /\ | | | | /\ /\ /\ /\ /\ /\ | \ محمد أ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
f45ed81821a4db35414275f4a1fc8e2d
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.Scanner; public class q5 { static long sum(String str){ long sum=0; for (int i = 0; i < str.length(); i++) { sum=sum+Long.parseLong(str.charAt(i)+""); } return sum; } public static void main(String[] args) { Scanner sc=new Scanner(System....
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
b3c8da5227bdb258fed0d5c34de39595
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.math.BigInteger; import java.util.*; import java.io.*; public class CFD { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; private static final long MOD = 1000L * 1000L * 1000L + 7; private static final int[] dx = {0, -1, 0, 1}; private static final int[] dy ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
c408ec08fa3b77273c3658f23108d685
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.System.exit; public class Main { public static void main(String[] args) { try { //inputStream = new FileInputStream(new File("./src/test.txt")); //outputStream = new FileOutputStream(new File...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
717c682e6a5880a99b816d9aa04172bb
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); StringBuilder out = new StringBuilder(); while(t-->0){ long n = sc.nextLong() , m = sc.nextInt(); long p ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
92a0d0cdd977b6125341a79ac4aef389
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.PriorityQueue; import java.util.StringTokenizer; public class D{ public static void main(String[] args) throws IOExce...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
ded5b8975e390aa4a875e3f9f6986df3
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Solution { public static void main(String[] args) throws IOException { Reader fs=new Reader(); // BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); // StringTokenizer st = new StringTokenizer(br.re...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
9dc29e6afdb6c142e3a1f66d614f1f31
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
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.io.Writer; import java.io.OutputStreamWriter; import java.io.Input...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
18e5903fdb2b7093dd83aa1a7d269311
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public final class CF { public static void main(String[]args)throws IOException { FastReader ob=new FastReader(); int t=ob.nextInt(); StringBuffer sb=new StringBuffer(); while(t-->0) { ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
678a2fda29bede13d16f26cbfa757269
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public final class CF { public static void main(String[]args)throws IOException { FastReader ob=new FastReader(); int t=ob.nextInt(); StringBuffer sb=new StringBuffer(); while(t-->0) { ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
25c4ec82b3ac5f9277f166ab6d9b4218
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static long dsum(long a) { long sum =0; while(a>0) { sum +=a%10; a /=10; } return sum; } public static long pow(int d) { long a=1; for (int ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
08292ae844bb44592f33452052f0c61b
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class round667D { public static void main(String s[]) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while(t-->0){ s=(...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
078bbabc7cb82564ceb781297d6a161d
train_001.jsonl
1599230100
You are given a positive integer $$$n$$$. In one move, you can increase $$$n$$$ by one (i.e. make $$$n := n + 1$$$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.You have to answer $$$t$$$ independent test cases.
256 megabytes
// package CodeForcesContests; import java.util.Scanner; public class zCF_667_3_D { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 1; i<= t; i++) { long num = sc.nextLong(); int sum = sc.nextInt(); long added = 0; long div = ...
Java
["5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1"]
2 seconds
["8\n0\n500\n2128012501878\n899999999999999999"]
null
Java 8
standard input
[ "greedy", "math" ]
50738d19041f2e97e2e448eff3feed84
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^{18}$$$; $$$1 \le s \le 162$$$).
1,500
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $$$n$$$ be less than or equal to $$$s$$$.
standard output
PASSED
1ae08229893ea5fa00b3086d0da3b3eb
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { // BufferedReader br = new BufferedReader(new InputStr...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
9a840da4e485494274fafffc979b7486
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; public class Main { public static void main(String[] args) { String isTrue = "No"; Scanner sc = new Scanner(System.in); int T = sc.nextInt(); sc.nextLine(); while(T>0) { int n = sc.nextInt(); Integer b[] = new Integer[n]; ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
dfa480abe2ab0da1866633a448cd35c4
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.Scanner; public class CF1445A{ public static void main(String[]args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); int x = sc.nextInt(); int a [] = new int[n]; int b [] = new int[n]; int c = 0; ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
4f6b5f8bd1c27ce88cdcc2391f3ea093
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
//package codeforce; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class pereuporyadMassiva { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int j = 0; j < t; j++) { int n = sc...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
c75675ec9b69f68684455e4a0d51cdce
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int k=sc.nextInt(); int ar[]=new int[n]; int br[]=new int[n]; for(int i=0;i<n;i++) ar[i]=sc.nextInt(); for(int i...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
e8f66e5be6477681c7e9d33b068b8d4d
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.*; import java.util.Arrays; public class JavaApplication12 { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(in.readLine()); for (int i = 0; i < t; i++) { ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
d5118b4a46af6a629d8c8295ce3f219b
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; //import java.io.*; //import java.lang.reflect.Array; public class div2$680 { public static void main(String args[]) { Scanner in =new Scanner(System.in); int t = in.nextInt(); // int i; while(t>0) { t--; int n = in.nextInt(); int k = in.nextInt(); int[] ar= new int[n]; in...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
72daa6284b94855dbfdd90baca05548b
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
//package olp; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class CF1145_A { public static void main(String[] args) { Scanner sc = new Scanner (System.in); int t = sc.nextInt(); while (t > 0) { int n, x; n = sc.nextInt();...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
72bfa4b693a855d5875ed69481011186
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.IOException; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i = 0; i < t; i++){ int n = sc.nextInt(); int x = sc.nextInt(); ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
bcb2b785534654266b1c87409e9fe9d9
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Arrayrearrange { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); int x = sc.nextI...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
2b9408997fb3e31d0191ddb29063f3a7
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; public class a { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while (t-- > 0) { int n = scn.nextInt(); int x = scn.nextInt(); int[] arr1 = new int[n]; int[] arr2...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
f2607d81f9517644141a5046ebccf12c
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; public class Array{ public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String linea; linea=br.read...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
ba44fcda41d337758999cc953f9bdc38
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; public class Solution { public static String arrange(int [] a, int [] b, int n, int k) { if (n == 1 && k < a[0]+b[0]) return "No"; if (n == 1 && k >= a[0]+b[0]) return "Yes"; Arrays.sort(a); Arrays.sort(b); for (int i=0; i<n; i++) {...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
1169bf0c7e55df817184958386899969
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
// _________________________RATHOD_____________________________________________________________ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class Main { static class Fast...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
1981d223df81c5517d2d88bf94127064
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.*; import java.util.Collections; import java.util.PriorityQueue; import java.util.StringTokenizer; public class FloorNumber { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
66ee395535bd019463e0e9e2cb35f86a
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.*; import java.util.*; /** * @username: sriman_chetan * @author: Chetan Raikwar * @date: 01-11-2020 */ public class Solution { public static void main(String[] args) throws IOException { try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
54334fb0b46914230757e554ecf4d387
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int flag = 0; while(t>0) { int n = sc.nextInt(); int x = sc.nextInt(); int a[] = new int[n]; int b[] = new int[n]; int tempArr[] = new int[n]; ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
2587aaee763182d5c9bf08807cca3bdc
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.Arrays; import java.util.Scanner; public class ArrayRearrangment { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); a: while (t-- > 0) { int n = scan.nextInt(); int[] a = new int[n]; ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
e1a9a3e4fef68abd40227604c6a41ac5
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class CodeTest { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); int n=0; int x =0; boolean bol=true; for(int i=0;i<t;i++) { n=s.nextInt(); x=s.nextInt(); I...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
f65d81266acceb58fdba226b21d9dac1
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; public class Solution{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t-->0){ int n = in.nextInt(); int x = in.nextInt(); Integer[] a = new Integer[n]; Integer[] b = ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
6cbd571199a9f5990d55de2c97339f5a
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; import java.io.*; public class ProblemA { public static String getResult(Long A[],Long B[],int n,Long x) { Arrays.sort(B,Collections.reverseOrder()); for(int i=0;i<n;i++) { if(A[i]+B[i]>x) return "No"; } return "Yes"; } public static void main(String[] args) throws IOException ...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
78096e98601941281884f1769e05a235
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; import java.util.Collections; public class test { public static void main(String[] args) { int n,x,max = 0,min = 0; Integer[] a=new Integer[1000]; Integer[] b=new Integer[1000]; int i,t,flag; test obj=new test(); Scanner sc=new Scanner(System.in); t=sc.nextInt(); while(t-->0) { n=sc.nextI...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
1e9dc12bb4e5021921e0f21ca1126540
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); i...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
5ee678ca45ff21374b91ad6d08f76f96
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; public class C680 { public static void main(String[] args)throws IOException { BufferedReader bReader=new BufferedReader(new InputStreamReader(System.in)); int T=Integer.parseInt(bRea...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
ebf7fc2dcb7d0a175579717751f7b2bb
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; public class test { public static void main (String[] args) { //code Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t>0){ t--; int n=s.nextInt(); int x = s.nextInt(); int a[]=new int[n]; f...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
2e570cbcd56be44addffdefe290bfd0c
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.io.*; import java.util.*; public class a { public static void main(String[] args) throws Exception { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); StringTokenizer st = new String...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
aff977386452a1c4439b9fff8a287d32
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
/* ⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⡎...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output
PASSED
b39a1fd181523120bf999f57e074eb45
train_001.jsonl
1604228700
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$).
512 megabytes
import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int x=sc.nextInt(); int a[]=new int[n]; int []b=new int[n]; for(...
Java
["4\n3 4\n1 2 3\n1 1 2\n\n2 6\n1 4\n2 5\n\n4 4\n1 2 3 4\n1 2 3 4\n\n1 5\n5\n5"]
1 second
["Yes\nYes\nNo\nNo"]
NoteIn the first test case, one can rearrange $$$b$$$ so it'll look like $$$[1, 2, 1]$$$. In this case, $$$1 + 1 \leq 4$$$; $$$2 + 2 \leq 4$$$; $$$3 + 1 \leq 4$$$.In the second test case, one can set $$$b$$$ to $$$[5, 2]$$$, then $$$1 + 5 \leq 6$$$; $$$4 + 2 \leq 6$$$.In the third test case, no matter how one shuffles ...
Java 8
standard input
[ "sortings", "greedy" ]
7e765c1b0e3f3e9c44de825a79bc1da2
The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. $$$t$$$ blocks follow, each describing an individual test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 50$$$; $$$1 \leq x \leq 1000$$$) — the length of arrays ...
800
For each test case print Yes if one can rearrange the corresponding array $$$b$$$ so that $$$a_i + b_i \leq x$$$ holds for each $$$i$$$ ($$$1 \le i \le n$$$) or No otherwise. Each character can be printed in any case.
standard output