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
8227f56664b5a59e4d79a297c01a3728
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.*; import java.io.*; public class B { private static int[] games = new int[1]; private static int[] sum1 = new int[1]; private static int[] sum2 = new int[1]; static int N; private static class pair implements Comparable<pair>{ int s; int t; public int compareTo(pair arg0) { int a = Double....
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
654b07caa2fe8f131281ea272374570d
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.List; import java.io.IOException; import java.io.InputStreamReader; import java.util.InputMismatchException; import java.util.ArrayList; import java.io.PrintStream; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; impo...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
9a5287fa1824309dceff0929b7736665
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.Comparator; public class C283_B { public static void main(String []args) { new Solution().solve(); } } class Solution { FastReader fr = new FastReader(); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); ...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
51e11d712f1d04fa28630f848562f402
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; import java.util.regex.*; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); br = new ...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
0cefdb92abc86598cf38623b25916921
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; /* try { inputStream = new FileInputStream("a.in"); outputStream = new FileOutputStream("a.out"); } catch ...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
cf87cb18874a250738464f2fc76e1175
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class ProblemB { BufferedReader rd; private ProblemB() throws IOException { rd = new BufferedReader(new InputStreamReader(System.in)); compute(); } private void comp...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
2e95f250afe03465534f420b0e37dc5e
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.*; import java.io.*; public class Main{ BufferedReader in; StringTokenizer str = null; PrintWriter out; private String next() throws Exception{ while (str == null || !str.hasMoreElements()) str = new StringTokenizer(in.readLine()); return str.nextToken(); ...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
81ce4ae0848057c21dbc34ebd0c65a21
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class B { static StringTokenizer...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
a364fb48e2dc814ad7f9f88f69f89369
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.*; import java.util.*; public class CopyOfB { void run() { int n = in.nextInt(); int[] a = new int[n]; int[] c = new int[n + 1]; for (int i = 0; i < n; i++) { a[i] = in.nextInt() - 1; if (a[i] < 0 || a[i] > 1) { throw new RuntimeException(); } c[i + 1] = c[i] + a[i]; } List<...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
1b1930f1ba9cb2c77f0396728b33baf7
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.*; import java.util.*; public class B { int n; int[] a; int[] c; int playFrom(int i, int t) { int low = i; int high = n + 1; while (low + 1 < high) { int m = (low + high) / 2; int win1 = c[m] - c[i]; int win0 = m - i - win1; if (Math.max(win0, win1) < t) { low = m; } else ...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
45dca65de4ebc86cc85622977a36e371
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable { class Res{ int s, t; Res(int s, int t){this.s = s; this.t = t;} } public void solve() throws IOException { int N = nextInt(); int[] a = new int[N]; for(int i = 0; ...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
6c42a9227a528776816db26adb829309
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.*; import java.io.*; public class E { FastScanner in; PrintWriter out; class Result implements Comparable<Result> { int inSet, inParty; public Result(int inSet, int inParty) { super(); this.inSet = inSet; this.inParty = inParty; } @Override public int compareTo(Result o) { ...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
5b3fd04232fceeff6eb306ca4f08eed4
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.BufferedWriter; import java.util.InputMismatchException; import java.util.ArrayList; import java.util.List; import java.util.NoSuchElementException; import java.math.BigInteger; import java.io.OutputStream; import java.util.Collections; import java.io.PrintWriter; import java.io.Writer; import java.io.IO...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
77a1d1ae86395423f434294b9fdfa43b
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.*; public class b { public static void main(String[] args) { Scanner input = new Scanner(System.in); n = input.nextInt(); int[] data = new int[n]; for(int i = 0; i<n; i++) data[i] = input.nextInt(); TreeSet<Pair> res = new TreeSet<Pair>(); precomp(data); for(int i = 1; i<=n;...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
faa7a615d386d8fc457ea4bff24475c3
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.ArrayList; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.util.List; import java.io.BufferedReader; import java.util.Map; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Collections; import java.io.IOException; import java.u...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
0d1333a05fbea02fe39162334bc8c2d0
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.awt.*; import java.io.*; import java.math.*; import java.util.*; import java.util.Map.Entry; import static java.lang.Math.*; public class solver implements Runnable { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new ...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
f4576065d023dc7f273fc63b8ca4f87b
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.*; import java.util.*; public class BMain { String noResultMessage = "NoResult"; Parser in = new Parser(); PrintWriter out; int n = in.nextInteger(); int[][] first = new int[17][140000]; int[][] second = new int[17][140000]; static class Answer { final int t; ...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
4f52fa3e1ace91857687053079cf4748
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.*; import java.util.*; public class D { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); class State implements Comparable<State> { int s, t; State(int s, int t) { this.s = s; this.t = t; } public int compareTo(State x) { return s - x.s...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
afd1f71499b1a316f8574b37c1f3f3ef
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Map.Entry; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.TreeSet; public class Main { public static void main(String[] arg...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
6d3c3200a0c6f74a94b8d52a9df3a238
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.List; import java.io.IOException; import java.util.InputMismatchException; import java.util.ArrayList; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Collections; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
adfbbda811f430c0b09b70aa386b49c0
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.List; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.util.ArrayList; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.math.BigInteger; import java.util.Collecti...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
ce6507c29fdb4073ef861742949d7da6
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
//package codeforces; 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.List; import java.util.StringTokenizer; public...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
2dca850cd8ce21708d4ddd408791123a
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.*; import java.util.*; import java.math.BigInteger; public class Main{ final boolean isFileIO = false; BufferedReader in; PrintWriter out; StringTokenizer st = new StringTokenizer(""); String delim = " "; public static void main(String[] args) throws IOException { Main ...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
06c7845f05cad90bc4133c1586ff1f37
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.InputMismatchException; import java.u...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
a5ea51386bca5cbc5432d958ad57958e
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.util.List; import java.io.IOException; import java.util.Arrays; import java.util.ArrayList; import java.util.Comparator; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Collections; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
d911af0ec426b5d53c2c424f3d229147
train_001.jsonl
1418833800
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
256 megabytes
import java.io.*; import java.util.*; public class tennisgame { private static Reader in; private static PrintWriter out; static class Pair implements Comparable<Pair> { public int a, b; public Pair (int a, int b) { this.a = a; this.b = b; } public String toString() { re...
Java
["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1"]
2 seconds
["2\n1 3\n3 1", "3\n1 4\n2 2\n4 1", "0", "3\n1 6\n2 3\n6 1"]
null
Java 7
standard input
[ "binary search", "implementation", "brute force" ]
eefea51c77b411640a3b92b9f2dd2cf1
The first line contains a single integer n — the length of the sequence of games (1 ≤ n ≤ 105). The second line contains n space-separated integers ai. If ai = 1, then the i-th serve was won by Petya, if ai = 2, then the i-th serve was won by Gena. It is not guaranteed that at least one option for numbers s and t corre...
1,900
In the first line print a single number k — the number of options for numbers s and t. In each of the following k lines print two integers si and ti — the option for numbers s and t. Print the options in the order of increasing si, and for equal si — in the order of increasing ti.
standard output
PASSED
8002c0d70c91f62ec45b249ebfee4d0e
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.util.*; public class NewYearTransportation{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int t = scan.nextInt(); int from = 0; int to = 0; ArrayList<Integer> a = new ArrayList<>(); int counter = 0; for(int i = 0; i < t-1; i++){ if...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
b0dc877d1ad3408f923b084fb2a95547
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.util.*; public class Main { public static int NN = 30010; public static Vector[] adj = new Vector[NN]; public static int[] vst = new int[NN]; public static void dfs(int u) { vst[u]=1; int n=adj[u].capacity(); for(int i=0; i<n; i++) { ...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
92e7176c3994c8e675313ffc9cf3f150
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(), t=in.nextInt(), id=1, ok=0; int[] a=new int[n+1]; for(int i=1; i<n; i++) { int x=in.nextInt(); if(id==i) id+=x; ...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
53016156299bb4e434c9fa08646ed4ef
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.io.*; import java.util.*; public class Test{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String[] s=br.readLine().split(" "); int n=Integer.parseInt(s[0]); int t=Integer.parseInt(s[1]); int[] go=new...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
3e6fff31605babbb7393dc7b0bd05766
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.util.*; public class Solution{ public static void main(String[] args){ Scanner s = new Scanner(System.in); int n = s.nextInt(); int t = s.nextInt(); int a[] = new int[n-1]; for(int i=0;i<n-1;i++){ a[i] = s.nextInt(); ...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
f3ca286b896dfaf1ce05e4058b1e4834
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class NewIO { static BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer tok; static boolean hasNext() ...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
f311ec4089c83663856725e04807db1c
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.Vector; /** * Created by...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
07aaed4b0273d6052b0d45c43bb5f2f3
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.io.*; import java.util.*; public class fivehundredA { public static void main(String [] som3a)throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String [] ayhaga = bf.readLine().split(" "); String [] portals = bf.readLine().split(" "); int index = ...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
5998a05c0d7404714901266c2741591a
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
//package CodeForces; import java.util.ArrayList; import java.util.Scanner; public class NewYearTransport { // final static int maxn = 3000; // static boolean [] mark = new boolean[maxn]; // static ArrayList [] graph = new ArrayList[maxn]; public static void main(String[] args) { Scanner sc = new Scanner(System.i...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
f214c54d8cb64acbd1527d4880557823
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.util.*; public class divarr{ public static void main(String s[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int arr[] = new int[n]; for(int i=1;i<n;i++) arr[i]=sc.nextInt(); boolean b=false; for(int i...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
50e45a9c6c2f15f66484827bb1dec414
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.util.Scanner; /** * Created by Женя on 07.03.2017. */ public class Task_500A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int all = in.nextInt(); int need = in.nextInt(); int[] a = new int[all]; for (int i = 1; i < all; i++)...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
515db47eeb3ab464ac9f343ee5db4685
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int input = in.nextInt(); int t = in.nextInt(); int[] input2 = new int[input ]; for (int i = 0; i < input - 1; i++) { input2[i] = in.nextInt();...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
d2c5dd2b3767bb50112ad3b1ddf7f5c7
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.io.*; public class Main { static Reader scan; static PrintWriter out; static int cities; static int destination; static int[] portals; public static void main(String[] args) throws IOException { scan = new Reader(); out = new PrintWriter(System.out, true); ...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
629698a739383f007d767f78ac9ea60b
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.io.*; //http://codeforces.com/problemset/problem/500/A public class Main { static Reader scan; static PrintWriter out; static int cities; static int destination; static int[] portals; public static void main(String[] args) throws IOException { scan = new Reader(); o...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
dfdcd9ac9223b0bbca0f587d1ade4750
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.io.*; public class Main { static Reader scan; static PrintWriter out; static int cities; static int destination; static int[] portals; //static boolean[] visited; public static void main(String[] args) throws IOException { scan = new Reader(); out = new PrintWr...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
0c5c41ab76b953489a8f6dfadba7dd6f
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class NewYearTransportation { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] temp = br.readLine().split(" "); int n = Integ...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
45f222d4879725f99d3a795609b58ec3
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int dest = sc.nextInt(); int cells[] = new int[n-1]; for(int i = 0; i < n - 1; i++) { cells[i] = sc.nextInt(); } sc.close(); // Starting position ...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
91095775ccb290a54b3e12493e19bf1d
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.util.Scanner; public class NewYearTransportation { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int size = sc.nextInt()-1; int num = sc.nextInt()-1; int[] arr = new int[size]; for(int i = 0;i<size;i++)arr[i]=sc.nextInt(); boolean works = false; for(int i = 0...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
828091f3a9c9eff3bfd2ccc93b3fb176
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.util.*; public class TestClass { public static void main(String args[] ) throws Exception { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int x=sc.nextInt(); int a[]=new int[n-1]; for(int i=0;i<n-1;i++) a[i]=sc.nextInt(); int y;...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
e9c646773edb2c66e0367ba55c563a96
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
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.StringTokenizer; public class F { public static void main(String[] args) throws IOException { FastScanner sc=new F...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
accff8c617ac15933eab1d82fbb06111
train_001.jsonl
1419951600
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.So, user tncks0121 has ma...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class newyear { public static void main (String[] args) throws IOException { // BufferedReader reader = new BufferedReader(new FileReader("newyear.in")); // PrintWriter writer = new PrintWriter(new FileWriter("newyear.out")); Buffer...
Java
["8 4\n1 2 1 2 1 2 1", "8 5\n1 2 1 2 1 1 1"]
2 seconds
["YES", "NO"]
NoteIn the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.
Java 8
standard input
[ "implementation", "dfs and similar", "graphs" ]
9ee3d548f93390db0fc2f72500d9eeb0
The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 104) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to. The second line contains n - 1 space-separated integers a1, a2, ..., an - 1 (1 ≤ ai ≤ n - i). It is guaranteed, that using the given transportation system, o...
1,000
If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".
standard output
PASSED
e0e2c1afb8b990d9984ee578b8755b90
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.util.List; import java.io.InputStreamReader; import java.io.IOException; import java.util.ArrayList; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.util.Collections; import java.io.InputStream...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
031e83addc42c12392b7951542ef4ef9
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class B { public static void main(String[] args) throws IOException { ...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
638464a09244d1974c33a416ef1c228b
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.util.*; import java.io.*; // Solution public class Main { public static void main (String[] argv) { new Main(); } boolean test = false; public Main() { FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in))); //FastReader in = new FastR...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
b6932d9eb68be40d3178933d00a44381
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
// package CF; import java.awt.Point; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Comparator; import java.util.PriorityQueue; import java.util.StringTokenizer; public cl...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
cd082b0dad27d375cd565a86989c727f
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ public static Integer INT(String s){ return Integer.parseInt(s); } public static Long LONG(String s){ return Long.parseLong(s); } //===================================================================================================================...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
d1087b6ba4a2a3428e4175f5a01fa4b5
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); int k = sc.nextInt(); ArrayList<Item> carts[] = ...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
c9a59ae703be9117983751f770676ec8
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.util.*; public class b161{ static class node { public int x,y; node() { } node(int a,int b) {x=a; y=b; } public int compare(node a,node b) { if(a.x>a.y) return -1; return 1; } } public static void main(String arg[]) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); int[] arr =...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
90662a8cdf9359bcef6a8c0dac9ad35c
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Queue; import java.util.Random;...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
883933a2c44071a258e5384d03949447
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class Discounts_CF161B { public static void...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
9347ffaf4563ea4f75507e0e4e79299c
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.util.*; public class Discounts { public static void main(String args[]) throws Exception { Scanner cin = new Scanner(System.in); int n = cin.nextInt(); int k = cin.nextInt(); int[] t = new int[2001]; int[] c = new int[2001]; int[] ind = new int[2001]; int[] kol = new int[2001]; int[] min =...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
8198c82239e639fe6f00cc0a8cbe50cb
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; import java.io.BufferedWriter; import java.io.Writer; import java.util.Collections; import java.io.OutputStreamWriter; import java.io.IOException; import java.util.InputMismatchEx...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
f4b3adb38b14ec8363bdff436b39c6b4
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; import java.io.BufferedWriter; import java.io.Writer; import java.util.Collections; import java.io.OutputStreamWriter; import java.io.IOException; import java.util.InputMismatchEx...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
433b6c77f64fdb3f0ad8d158cd0598a6
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.util.*; import java.util.stream.Collectors; import java.io.*; public class Discounts { /************************ SOLUTION STARTS HERE ************************/ static class Item { int idx , cost , type; Item (int... arg) { idx = arg[0]; cos...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
e52c13d8e5ece2b1c14103a06219dbed
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; import java.io.*; public class codeforces { static class Student{ int x,y;//z; Student(int x,int...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
2a8d252465e2817fb49f8d11bad0f743
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; public class Main { //SOLUTION BEGIN //Into the Hardware Mode void pre() throws Exception{} void solve(int TC) throws Exception { int N = ni(), K = ni(); long[][] P = new long[N][2]; for(int i = 0; i< N; i++)P[i] = new lo...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
d77e07d19a73ea40de3c6e79e6171137
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.*; import java.util.Comparator; import java.util.PriorityQueue; /** * Created by wencan on 2015/6/9. */ public class Discounts { public static void main(String[] args) throws IOException { Discounts discounts = new Discounts(); discounts.resolve(); } private void resolve()...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
284dfefa4c72b7c2fafcf763fb64f3c5
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static final long MOD = 1000000007L; static final int INF = 50000000; public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter pw = new PrintWriter(System.out); int N = sc.ni(); int K = sc.ni(...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
83e97103728c232bfe94710ae9e1fd20
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class templ { int binarySearch(int arr[], int l, int r, int x) { if (r >= l) { int mid = l + (r - l)/2; if (arr[mid] == x) return mid; if (arr[mid] > x) return binary...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 8
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
9f414e0c281057f4ff9fb62114ba78dd
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.*; import java.util.concurrent.ArrayBlockingQueue; import javax.print.attribute.HashAttributeSet; public class CodeForces { public void solve() throws IOException { int n = nextInt(); int k = nextInt(); List<Res...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 6
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
1c0a55fada76c9b5a818e0c577a09dac
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.*; import java.util.*; public class TaskB { BufferedReader br; PrintWriter out; StringTokenizer stok; String nextToken() throws IOException { while (stok == null || !stok.hasMoreTokens()) { String s = br.readLine(); if (s == null) { return null; } stok = new StringTokenizer(s); ...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 6
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
11ac0741b96c436b491bee0611d405ce
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.IOException; import java.io.PrintWriter; import java.util.*; /** * Created by IntelliJ IDEA. * User: katalexey@yandex-team.ru * Date: 11.03.12 */ public class B { public static void main(String[] args) throws IOException { Scanner r = new Scanner(System.in); // BufferedReader r = ...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 6
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
aeeb9c9bb618cbfaef527ea5f108e58b
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; /** * Discounts * * One day Polycarpus stopped by a supermarket on his way home. It turns out * that the supermarket is having a special offer for stools. The offer is as * follows: if a customer's shopping cart contains at least o...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 6
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
24cc6c37f9e5f1d5768557bd8ea80218
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.LinkedList; import java.util.List; import java.util.Queue; public class B { public static void...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 6
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
9297951d71cbc2fa9dca089191db2d8d
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class b extends Thread { BufferedReader bf; PrintWriter out; FastScanner in; void solve() throws Exception { int n = in.nextInt(); int k = in.nextInt(); point a[] = new point[n]; for (int i = 0; i<n; i++) a[i] = new point(in.nextInt(), ...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 6
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
5a26fc926ab21865e71a001d4449227a
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import static java.lang.Math.*; import static java.lang.System.currentTimeMillis; import static java.lang.System.exit; import static java.lang.System.arraycopy; import static java.util.Arrays.sort; import static java.util.Arrays.binarySearch; import static java.util.Arrays.fill; import java.util.*; import java.io.*; p...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 6
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
5025a7d7ad47f169ba069e85f86285a0
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.io.*; import java.util.*; public class Discount { public static void main(String[] args) { new Discount().run(); } BufferedReader br; StringTokenizer st; PrintWriter out; boolean eof = false; Random rand = new Random(12345); private void run() { Locale.setDefault(Locale.US); try { br = n...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 6
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
5f09872e0b399115105b011134e36936
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
/** * Jerry Ma * Program discounts */ import java.io.*; import java.util.*; public class discounts { static BufferedReader cin; static StringTokenizer tk; public static void main (String [] args) throws IOException { init(); Item [] stools = new Item[1000], pencils = new Item[1000]; Item [] [] ca...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 6
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
ca94517eba7c67bf6341d8f38b299f39
train_001.jsonl
1331478300
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class B { static int min(int a, int b) { return (a > b ? b : a); } static int max(int a, int b) { return (a > b ? a : b); } /** * @param args */ public static void m...
Java
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
3 seconds
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.
Java 6
standard input
[ "constructive algorithms", "sortings", "greedy" ]
06c7834aa4d06d6fcebfa410054f1b8c
The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an intege...
1,700
In the first line print a single real number with exactly one decimal place — the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
standard output
PASSED
8c69fbce2a71e0ab20afa0d4fa838742
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import java.io.*; import java.util.*; public class F { FastScanner in; PrintWriter out; void solve() { int n = in.nextInt(); int m = in.nextInt(); List<Edge>[] g = new List[n]; for (int i = 0; i < n; i++) { g[i] = new ArrayList<>(); } for (int i ...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
988def9e6ee50f60c95f73e44d85a46e
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import java.util.*; import java.io.*; public class KoalaNotebook { static final int maxsz = 1000000; static final long mod = 1000000007L; static ArrayList<Edge>[] graph; static int top; public static void main(String[] args) { FastScanner scanner = new FastScanner(); PrintWriter out...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
06c7c0f04d0df5ac12fa3a17565f098b
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelpe...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
df6535c5f84fbe49309d9d838d34c566
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import java.util.*; import java.io.*; public class F { static final long mod = 1000000007; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); StringTokeni...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
1dbdb5bc9e30e11f438a78a9def0be87
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import java.util.*; import java.io.*; public class F { static final long mod = 1000000007; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); StringTokeni...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
93cd0b6a0a6671f3e4e4f44f08ea4bc8
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Math.max; import static java.lang.System.arraycopy; import static java.lang.System.exit; import static java.util.Arrays.copyOf; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
4b92f199b382c13ca6748ed2ed718de0
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.io.IOException; import java.util.TreeSet; import java.util.ArrayList; import java.io.UncheckedIOException; import java.util.List; import java.io.Closeable; import java.i...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
85ce1ef2c35a1c351d3619b87529ffa0
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.io.IOException; import java.util.TreeSet; import java.util.ArrayList; import java.io.UncheckedIOException; import java.util.List; import java.io.Closeable; import java.i...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
c8bbfd474159c306c891a22885b41119
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.TreeSet; public class CFContest { public static void main(String[] a...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
9cdecc0edd1ed7f6ff1b347759066271
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.io.FileNotFoundException; import java.util.ArrayList; import java.security.SecureRandom; import java.util.Li...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
4215a263031b78ffde022555202cd155
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
//package round584; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.InputMismatchExceptio...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
851ca62400ed2a464e924d632db884ce
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import java.io.*; import java.util.*; import java.math.BigInteger; import java.util.Map.Entry; import static java.lang.Math.*; public class F extends PrintWriter { final long mod = 1_000_000_000 + 7; int k = 20; class Node implements Comparable<Node> { final int len; final long hash; ...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
c825b61c5e35ff9ddb9ced0262937397
train_001.jsonl
1568466300
Koala Land consists of $$$m$$$ bidirectional roads connecting $$$n$$$ cities. The roads are numbered from $$$1$$$ to $$$m$$$ by order in input. It is guaranteed, that one can reach any city from every other city.Koala starts traveling from city $$$1$$$. Whenever he travels on a road, he writes its number down in his no...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["11 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11", "12 19\n1 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 11\n11 12\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10", "12 14\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n1 3\n1 4\n1 10"]
2 seconds
["1\n12\n123\n1234\n12345\n123456\n1234567\n12345678\n123456789\n345678826", "1\n12\n13\n14\n15\n16\n17\n18\n19\n1210\n121011", "1\n12\n13\n134\n1345\n13456\n1498\n149\n14\n1410\n141011"]
null
Java 8
standard input
[ "graphs", "shortest paths", "data structures", "dfs and similar", "trees", "strings" ]
b70b03c888876e8979a7990c22229194
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5, n - 1 \le m \le 10^5$$$), the number of cities and the number of roads, respectively. The $$$i$$$-th of the following $$$m$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$), representing a bid...
2,600
Print $$$n - 1$$$ integers, the answer for every city except for the first city. The $$$i$$$-th integer should be equal to the smallest number he could have written for destination $$$i+1$$$. Since this number may be large, output its remainder modulo $$$10^9+7$$$.
standard output
PASSED
79eeb7034b27e53261679b6b24fc87e6
train_001.jsonl
1505653500
There are n phone numbers in Polycarp's contacts on his phone. Each number is a 9-digit integer, starting with a digit different from 0. All the numbers are distinct.There is the latest version of Berdroid OS installed on Polycarp's phone. If some number is entered, is shows up all the numbers in the contacts for which...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); StringTokenizer s = new ...
Java
["3\n123456789\n100000000\n100123456", "4\n123456789\n193456789\n134567819\n934567891"]
4 seconds
["9\n000\n01", "2\n193\n81\n91"]
null
Java 11
standard input
[ "data structures", "implementation", "brute force", "strings" ]
37d906de85f173aca2a9a3559cbcf7a3
The first line contains single integer n (1 ≤ n ≤ 70000) — the total number of phone contacts in Polycarp's contacts. The phone numbers follow, one in each line. Each number is a positive 9-digit integer starting with a digit from 1 to 9. All the numbers are distinct.
1,600
Print exactly n lines: the i-th of them should contain the shortest non-empty sequence of digits, such that if Polycarp enters it, the Berdroid OS shows up only the i-th number from the contacts. If there are several such sequences, print any of them.
standard output
PASSED
e23d3ead57d34c19110484c00fce2511
train_001.jsonl
1505653500
There are n phone numbers in Polycarp's contacts on his phone. Each number is a 9-digit integer, starting with a digit different from 0. All the numbers are distinct.There is the latest version of Berdroid OS installed on Polycarp's phone. If some number is entered, is shows up all the numbers in the contacts for which...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner s=new Scanner(System.in); int n=s.nextInt(); ArrayList<String>list=new ArrayList<>(); for(int i=0;i<n;i++) { list.add(s.next()); } HashSet<String>hs=new HashSet<>(); H...
Java
["3\n123456789\n100000000\n100123456", "4\n123456789\n193456789\n134567819\n934567891"]
4 seconds
["9\n000\n01", "2\n193\n81\n91"]
null
Java 11
standard input
[ "data structures", "implementation", "brute force", "strings" ]
37d906de85f173aca2a9a3559cbcf7a3
The first line contains single integer n (1 ≤ n ≤ 70000) — the total number of phone contacts in Polycarp's contacts. The phone numbers follow, one in each line. Each number is a positive 9-digit integer starting with a digit from 1 to 9. All the numbers are distinct.
1,600
Print exactly n lines: the i-th of them should contain the shortest non-empty sequence of digits, such that if Polycarp enters it, the Berdroid OS shows up only the i-th number from the contacts. If there are several such sequences, print any of them.
standard output
PASSED
4e68049968b6a6ec575562cada8a563a
train_001.jsonl
1505653500
There are n phone numbers in Polycarp's contacts on his phone. Each number is a 9-digit integer, starting with a digit different from 0. All the numbers are distinct.There is the latest version of Berdroid OS installed on Polycarp's phone. If some number is entered, is shows up all the numbers in the contacts for which...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); StringTokenizer s = new ...
Java
["3\n123456789\n100000000\n100123456", "4\n123456789\n193456789\n134567819\n934567891"]
4 seconds
["9\n000\n01", "2\n193\n81\n91"]
null
Java 11
standard input
[ "data structures", "implementation", "brute force", "strings" ]
37d906de85f173aca2a9a3559cbcf7a3
The first line contains single integer n (1 ≤ n ≤ 70000) — the total number of phone contacts in Polycarp's contacts. The phone numbers follow, one in each line. Each number is a positive 9-digit integer starting with a digit from 1 to 9. All the numbers are distinct.
1,600
Print exactly n lines: the i-th of them should contain the shortest non-empty sequence of digits, such that if Polycarp enters it, the Berdroid OS shows up only the i-th number from the contacts. If there are several such sequences, print any of them.
standard output
PASSED
fe5ab2981febdb6d66e3218fb80eb7a1
train_001.jsonl
1505653500
There are n phone numbers in Polycarp's contacts on his phone. Each number is a 9-digit integer, starting with a digit different from 0. All the numbers are distinct.There is the latest version of Berdroid OS installed on Polycarp's phone. If some number is entered, is shows up all the numbers in the contacts for which...
256 megabytes
//package Coding; import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner s=new Scanner(System.in); int n=s.nextInt(); ArrayList<String>list=new ArrayList<>(); for(int i=0;i<n;i++) { list.add(s.next()); } HashSet<String>hs=n...
Java
["3\n123456789\n100000000\n100123456", "4\n123456789\n193456789\n134567819\n934567891"]
4 seconds
["9\n000\n01", "2\n193\n81\n91"]
null
Java 11
standard input
[ "data structures", "implementation", "brute force", "strings" ]
37d906de85f173aca2a9a3559cbcf7a3
The first line contains single integer n (1 ≤ n ≤ 70000) — the total number of phone contacts in Polycarp's contacts. The phone numbers follow, one in each line. Each number is a positive 9-digit integer starting with a digit from 1 to 9. All the numbers are distinct.
1,600
Print exactly n lines: the i-th of them should contain the shortest non-empty sequence of digits, such that if Polycarp enters it, the Berdroid OS shows up only the i-th number from the contacts. If there are several such sequences, print any of them.
standard output
PASSED
a7b071f509c53a2be4ab757c04bf8c9c
train_001.jsonl
1467822900
Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that ). You are given two integers n and k and n closed intervals [li, ri] on OX axis and you h...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.function.Function; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.Map.Entry; public class Main implements Runnable { static final int MOD = (int) 1e9 + 7; ...
Java
["3 2\n1 2\n1 3\n2 3", "3 3\n1 3\n1 3\n1 3", "3 1\n1 2\n2 3\n3 4"]
3 seconds
["5", "3", "6"]
NoteIn the first example: ;;.So the answer is 2 + 1 + 2 = 5.
Java 8
standard input
[ "dp", "geometry", "combinatorics", "implementation", "data structures" ]
900c85e25d457eb8092624b1d42be2a2
The first line contains two integers n and k (1 ≤ k ≤ n ≤ 200 000) — the number of segments and the number of segments in intersection groups respectively. Then n lines follow, the i-th line contains two integers li, ri ( - 109 ≤ li ≤ ri ≤ 109), describing i-th segment bounds.
2,000
Print one integer number — the answer to Mike's problem modulo 1000000007 (109 + 7) in the only line.
standard output
PASSED
bf480244d923f3234838e3d8c7cc7791
train_001.jsonl
1467822900
Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that ). You are given two integers n and k and n closed intervals [li, ri] on OX axis and you h...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.function.Function; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.Map.Entry; public class Main implements Runnable { static final int MOD = (int) 1e9 + 7; ...
Java
["3 2\n1 2\n1 3\n2 3", "3 3\n1 3\n1 3\n1 3", "3 1\n1 2\n2 3\n3 4"]
3 seconds
["5", "3", "6"]
NoteIn the first example: ;;.So the answer is 2 + 1 + 2 = 5.
Java 8
standard input
[ "dp", "geometry", "combinatorics", "implementation", "data structures" ]
900c85e25d457eb8092624b1d42be2a2
The first line contains two integers n and k (1 ≤ k ≤ n ≤ 200 000) — the number of segments and the number of segments in intersection groups respectively. Then n lines follow, the i-th line contains two integers li, ri ( - 109 ≤ li ≤ ri ≤ 109), describing i-th segment bounds.
2,000
Print one integer number — the answer to Mike's problem modulo 1000000007 (109 + 7) in the only line.
standard output
PASSED
b76b13d0749d52ec390ac613e965a0aa
train_001.jsonl
1467822900
Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that ). You are given two integers n and k and n closed intervals [li, ri] on OX axis and you h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class E { static final long MODULO = 1000000007; public static void ...
Java
["3 2\n1 2\n1 3\n2 3", "3 3\n1 3\n1 3\n1 3", "3 1\n1 2\n2 3\n3 4"]
3 seconds
["5", "3", "6"]
NoteIn the first example: ;;.So the answer is 2 + 1 + 2 = 5.
Java 8
standard input
[ "dp", "geometry", "combinatorics", "implementation", "data structures" ]
900c85e25d457eb8092624b1d42be2a2
The first line contains two integers n and k (1 ≤ k ≤ n ≤ 200 000) — the number of segments and the number of segments in intersection groups respectively. Then n lines follow, the i-th line contains two integers li, ri ( - 109 ≤ li ≤ ri ≤ 109), describing i-th segment bounds.
2,000
Print one integer number — the answer to Mike's problem modulo 1000000007 (109 + 7) in the only line.
standard output
PASSED
6810b19d8385de2cc04b69e9f5f863e0
train_001.jsonl
1467822900
Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that ). You are given two integers n and k and n closed intervals [li, ri] on OX axis and you h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class E { static final long MODULO = 1000000007; public static void ...
Java
["3 2\n1 2\n1 3\n2 3", "3 3\n1 3\n1 3\n1 3", "3 1\n1 2\n2 3\n3 4"]
3 seconds
["5", "3", "6"]
NoteIn the first example: ;;.So the answer is 2 + 1 + 2 = 5.
Java 8
standard input
[ "dp", "geometry", "combinatorics", "implementation", "data structures" ]
900c85e25d457eb8092624b1d42be2a2
The first line contains two integers n and k (1 ≤ k ≤ n ≤ 200 000) — the number of segments and the number of segments in intersection groups respectively. Then n lines follow, the i-th line contains two integers li, ri ( - 109 ≤ li ≤ ri ≤ 109), describing i-th segment bounds.
2,000
Print one integer number — the answer to Mike's problem modulo 1000000007 (109 + 7) in the only line.
standard output
PASSED
87cc00704b1ea0f19dda78b60e06227e
train_001.jsonl
1467822900
Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that ). You are given two integers n and k and n closed intervals [li, ri] on OX axis and you h...
256 megabytes
import java.util.ArrayList; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Collections; import java.util.Comparator; import java.io.IOException; import java.util.StringTokenizer...
Java
["3 2\n1 2\n1 3\n2 3", "3 3\n1 3\n1 3\n1 3", "3 1\n1 2\n2 3\n3 4"]
3 seconds
["5", "3", "6"]
NoteIn the first example: ;;.So the answer is 2 + 1 + 2 = 5.
Java 8
standard input
[ "dp", "geometry", "combinatorics", "implementation", "data structures" ]
900c85e25d457eb8092624b1d42be2a2
The first line contains two integers n and k (1 ≤ k ≤ n ≤ 200 000) — the number of segments and the number of segments in intersection groups respectively. Then n lines follow, the i-th line contains two integers li, ri ( - 109 ≤ li ≤ ri ≤ 109), describing i-th segment bounds.
2,000
Print one integer number — the answer to Mike's problem modulo 1000000007 (109 + 7) in the only line.
standard output
PASSED
24b977e1c74754abd3ca4ae264c48b66
train_001.jsonl
1467822900
Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that ). You are given two integers n and k and n closed intervals [li, ri] on OX axis and you h...
256 megabytes
import java.util.*; import java.io.*; // Main public class Main { public static void main (String[] argv) { new Main(); } boolean test = false; TreeMap<Integer, Integer> map = new TreeMap<>(); long mod = 1000000007; public Main() { FastReader in = new FastReader(new BufferedRead...
Java
["3 2\n1 2\n1 3\n2 3", "3 3\n1 3\n1 3\n1 3", "3 1\n1 2\n2 3\n3 4"]
3 seconds
["5", "3", "6"]
NoteIn the first example: ;;.So the answer is 2 + 1 + 2 = 5.
Java 8
standard input
[ "dp", "geometry", "combinatorics", "implementation", "data structures" ]
900c85e25d457eb8092624b1d42be2a2
The first line contains two integers n and k (1 ≤ k ≤ n ≤ 200 000) — the number of segments and the number of segments in intersection groups respectively. Then n lines follow, the i-th line contains two integers li, ri ( - 109 ≤ li ≤ ri ≤ 109), describing i-th segment bounds.
2,000
Print one integer number — the answer to Mike's problem modulo 1000000007 (109 + 7) in the only line.
standard output
PASSED
3d6fde4507769ccd4ec12bbdc7a047aa
train_001.jsonl
1467822900
Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that ). You are given two integers n and k and n closed intervals [li, ri] on OX axis and you h...
256 megabytes
import java.util.*; import java.io.*; // Main public class Main { public static void main (String[] argv) { new Main(); } boolean test = false; class Event implements Comparable<Event> { int x, val; public Event(int x, int val) { this.x=x; this.val = val; ...
Java
["3 2\n1 2\n1 3\n2 3", "3 3\n1 3\n1 3\n1 3", "3 1\n1 2\n2 3\n3 4"]
3 seconds
["5", "3", "6"]
NoteIn the first example: ;;.So the answer is 2 + 1 + 2 = 5.
Java 8
standard input
[ "dp", "geometry", "combinatorics", "implementation", "data structures" ]
900c85e25d457eb8092624b1d42be2a2
The first line contains two integers n and k (1 ≤ k ≤ n ≤ 200 000) — the number of segments and the number of segments in intersection groups respectively. Then n lines follow, the i-th line contains two integers li, ri ( - 109 ≤ li ≤ ri ≤ 109), describing i-th segment bounds.
2,000
Print one integer number — the answer to Mike's problem modulo 1000000007 (109 + 7) in the only line.
standard output
PASSED
e9390bbc80778a095373f50db58deeb9
train_001.jsonl
1467822900
Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that ). You are given two integers n and k and n closed intervals [li, ri] on OX axis and you h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class E { static final long MODULO = 1000000007; public static void ...
Java
["3 2\n1 2\n1 3\n2 3", "3 3\n1 3\n1 3\n1 3", "3 1\n1 2\n2 3\n3 4"]
3 seconds
["5", "3", "6"]
NoteIn the first example: ;;.So the answer is 2 + 1 + 2 = 5.
Java 8
standard input
[ "dp", "geometry", "combinatorics", "implementation", "data structures" ]
900c85e25d457eb8092624b1d42be2a2
The first line contains two integers n and k (1 ≤ k ≤ n ≤ 200 000) — the number of segments and the number of segments in intersection groups respectively. Then n lines follow, the i-th line contains two integers li, ri ( - 109 ≤ li ≤ ri ≤ 109), describing i-th segment bounds.
2,000
Print one integer number — the answer to Mike's problem modulo 1000000007 (109 + 7) in the only line.
standard output