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
52d3396a657f3e65b158bad9f4f51c31
train_002.jsonl
1289232000
One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of dollars and then sell it no more than once in n days. According to Mar...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class test { // static boolean sf[]; public static void main(String[] args) { // int test = fs.nextInt(); int test = 1; for (int cases = 0; cases < test; cases++) { int n=fs.nextInt(); int k=fs.nextInt(); int ar[]=getintarray(n); int ...
Java
["2 4\n3 7", "4 10\n4 3 2 1", "4 10\n4 2 3 1"]
2 seconds
["8", "10", "15"]
null
Java 11
standard input
[ "brute force" ]
2c9133650d831fa6ab4c11661bcb9cbb
The first line contains two integers n and b (1 ≤ n, b ≤ 2000) — the number of days and the initial number of money in bourles. The next line contains n integers ai (1 ≤ ai ≤ 2000) — the prices of Martian dollars.
1,400
Print the single number — which maximal sum of money in bourles can Vasya get by the end of day n.
standard output
PASSED
2b6b44feb7604b04cef3ed5944693676
train_002.jsonl
1289232000
One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of dollars and then sell it no more than once in n days. According to Mar...
256 megabytes
/** * @author egaeus * @mail sebegaeusprogram@gmail.com * @veredict Not sended * @url <https://codeforces.com/problemset/problem/41/B> * @category ? * @date 14/06/2020 **/ import java.io.*; import java.util.*; import static java.lang.Integer.*; import static java.lang.Math.*; public class CF41B { public ...
Java
["2 4\n3 7", "4 10\n4 3 2 1", "4 10\n4 2 3 1"]
2 seconds
["8", "10", "15"]
null
Java 11
standard input
[ "brute force" ]
2c9133650d831fa6ab4c11661bcb9cbb
The first line contains two integers n and b (1 ≤ n, b ≤ 2000) — the number of days and the initial number of money in bourles. The next line contains n integers ai (1 ≤ ai ≤ 2000) — the prices of Martian dollars.
1,400
Print the single number — which maximal sum of money in bourles can Vasya get by the end of day n.
standard output
PASSED
006cb72588d71ca88dfa87ba5c37d079
train_002.jsonl
1289232000
One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of dollars and then sell it no more than once in n days. According to Mar...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static class Pair { public int x, y, id; public Pair() { x = y = 0; } public Pair(int x, int y, int i) { this.x = x; this.y = y; id = i; } } static long INF = (long) (1000000000); public static void main...
Java
["2 4\n3 7", "4 10\n4 3 2 1", "4 10\n4 2 3 1"]
2 seconds
["8", "10", "15"]
null
Java 11
standard input
[ "brute force" ]
2c9133650d831fa6ab4c11661bcb9cbb
The first line contains two integers n and b (1 ≤ n, b ≤ 2000) — the number of days and the initial number of money in bourles. The next line contains n integers ai (1 ≤ ai ≤ 2000) — the prices of Martian dollars.
1,400
Print the single number — which maximal sum of money in bourles can Vasya get by the end of day n.
standard output
PASSED
c5a1732c4aa545944c7b9b228a59662a
train_002.jsonl
1289232000
One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of dollars and then sell it no more than once in n days. According to Mar...
256 megabytes
import java.io.*; import java.util.*; public class MyClass { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == n...
Java
["2 4\n3 7", "4 10\n4 3 2 1", "4 10\n4 2 3 1"]
2 seconds
["8", "10", "15"]
null
Java 11
standard input
[ "brute force" ]
2c9133650d831fa6ab4c11661bcb9cbb
The first line contains two integers n and b (1 ≤ n, b ≤ 2000) — the number of days and the initial number of money in bourles. The next line contains n integers ai (1 ≤ ai ≤ 2000) — the prices of Martian dollars.
1,400
Print the single number — which maximal sum of money in bourles can Vasya get by the end of day n.
standard output
PASSED
e741afdb447d4444fc63b93878e7fe6b
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.Scanner; import java.util.TreeSet; public class Numbers { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(), k = scan.nextInt(); if(n == 1){ if(k > 0) System.out.println(-1); else System.out.println(1); } else if(n/2 > k) System.ou...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
452fd50c432b1cb4e5eba86e12856e20
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.*; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); if (k < n / 2 || (n == 1 && k > 0) ) { System.out.println(-1); } else if (n == 1) { System.ou...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
ec184e160e55c7c3255eadbafd97ec1e
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.*; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); if(n==1) { if(k!=0) { System.out.print(-1); return; } else { ...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
e9442d9b750be20f293f08f9bd8e51af
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.*; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); if (k < n / 2 || (n == 1 && k > 0) ) { System.out.println(-1); return; } if (n == 1)...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
691c36e6b2ca21a79a240603f464ee97
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.*; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); if(n==1) { if(k!=0) { System.out.print("-1"); return; } else if(k==0)...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
8d7844a908868bdaabdf584c48839b0c
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner jin = new Scanner(System.in); long n = jin.nextLong(); long k = jin.nextLong(); if (n == 1 && k == 0) { System.out.println(1); return; } if (n =...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
4b03e0939deba70241dbf1ecb5130a70
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main2 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int n = ...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
7209c37ad6535678c36494778cf54d6c
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.awt.Point; import java.awt.geom.Line2D; import java.io.BufferedReader; import java.io.OutputStream; 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; impor...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
37787495ad4c346de61a7d30bb6b80c8
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
//package CF; 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.StringTokenizer; public class A { public static void main(String[] args) throws Exception { Scanner b...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
3cd200e17bfe84aa265bf5c54552ffac
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; /** * @author Don Li */ public class MashmokhNumbers { int N = (int) 2e6 + 5; boolean[] prime = new boolean[N]; int...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
bc47c36b4665fdd7d534018b111a7c0f
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
//package com.a2onlinejudge.ladder.CodeforcesDiv2C; import java.io.*; import java.util.*; public final class MashmokhAndNumbers { public static void main(String[] args) { InputReader in = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); Solver solver = new Solver...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
b7ad45ef8d411303bb9ad9d488947dcd
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.io.*; import java.util.*; public class CF415C { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int k = Integer.p...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
ede1ed675539decddcfa6294050de4df
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * * @author Aditya Joshi */ public class Main { public static void main(String[] args) { MyScanner sc = new MyScanner(); int n = sc.nextInt(); bool...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
eaa436d979e874a6e77c1c9cc97951e7
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
//package vc; import java.util.Scanner; public class c { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); if(n==1) { if(k!=0) { System.out.println("-1"); return; } else if(k==0) { System.out.println("1"); ret...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
76b7064de3f2799260ce72b9302a7b5f
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package MASHNUM; import java.util.Scanner; /** * * @author nsekhar */ public class Main { public static void main(String[] ...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
240ee666243c3d10c646c825431f6dcb
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.Scanner; public class Fourthq { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner input = new Scanner (System.in); int n = input.nextInt(); int [] array = new int [n...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
3a1ddfac70200cd41adb6d6afa662082
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.*; import java.io.*; public class C { static BufferedReader in; static PrintWriter out; static { try { in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter(new FileWriter("output.txt")); } catch (Exception e) { in =...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
b468744c0cba4e3f153549b79301d972
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashSet; import java.util.StringTokenizer; public class Codeforces_240_C { public static int gcd(int a, int b) { return...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
5a0a578edcbf515890b1d054d68ea926
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) throws Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStr...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
4e9f77086b1bdfeed478e702051a332c
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.lang.reflect.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(out...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
3cf92c891edbc047a449ca319a869e24
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.Scanner; public class Q415C { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int half = n/2; if(half > k || (n == 1 && k != 0)) System.out.println("-1"); else ...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
835c346847c7c09134a71498303dc5aa
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.StringTokenizer; import java.util.Tree...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
46042961ebd064ed8a9938332c179c87
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ static PrintWriter out=new PrintWriter(System.out); public static void main (String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String[] temp=br.readLine().trim().split(" "); int n=Inte...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
e65d3fd3ee39dd27c0ce68c6800de569
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import java.io.File; import java.io.FileNotFoundException; import java.util.StringTokenize...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
c9fb11ba3703481eec2329858198110c
train_002.jsonl
1396798800
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
256 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Scanner; /** * * @author max19 */ public class Contest { public static void mashmohAndBimoh(){ Scanner scan = new Scanner(System.in); String condition = scan.nextLine(); String[] condNumbers = condition.split...
Java
["5 2", "5 3", "7 2"]
1 second
["1 2 3 4 5", "2 4 3 7 1", "-1"]
Notegcd(x, y) is greatest common divisor of x and y.
Java 8
standard input
[ "constructive algorithms", "number theory", "greedy" ]
b85c8bfbe67a23a81bef755f9313115a
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
1,500
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
standard output
PASSED
c5f5e3b76d640646deebf894501a3200
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.lang.*; import java.util.*; public class C346 { Scanner sc = new Scanner(System.in); int n, m, x = 0, ans =0, y = 0; int [] used = new int[200005]; int [] value = new int[200005]; public void input() { n = sc.nextInt(); m = sc.nextInt(); for(int i = 0; i < n; i++) value[i] = sc.nextInt(...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
a0cdae133831d7b2bde5b8d129b0f0b3
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Scanner; import java.util.TreeSet; import org.omg.CORBA.IMP_LIMIT; public class CodeJam1 { public static void main(String[] ...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
a2b625cf906a8893cad96f1fd19b9550
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.StringTokenizer;...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
725fe4e5e56ee9b738eb8f6b76f5aa4d
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.StringTokenizer; public class R346Div2C { public static void main(String[] args) { FastScanner in=new FastScanner(); int n=in.nextInt(); int m=in.n...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
6d4fa6946987341549825be1ed1452fb
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.Arrays; import java.util.HashSet; import java.util.Map; import java.util.Scanner; import java.util.Set; public class MainC { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 100000...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
4ebd8aa47d2fccf502d06163e0018e2c
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); Set<Integer> a = new HashSet<>(); for (int i = 0; i < n; i++) { a.add(sc.nextInt()); } int count = 0; ...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
41b0e3ab278df7a416221d3d3def3601
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.*; import java.io.*; public class CF659C{ private static InputStream stream; private static byte[] buf = new byte[1024]; private static int curChar; private static int numChars; private static SpaceCharFilter filter; private static PrintWriter pw; private static void soln(){ int n=nextInt...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
72f3db098db637f13f6e7bb6cfc0097f
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.awt.Point; 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.List; import java.util.StringTokenizer; public class C { static BufferedReader br = new BufferedReader(...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
2bfc83ba7803a6c993aa53294f5b392e
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.*; public final class TanyaToys { public static void main(String[] args) { Scanner br=new Scanner(System.in); int n=br.nextInt(); int m=br.nextInt(); int[] a=new int[n]; int c=0; StringBuilder str=new StringBuilder(""); for(int i=0;i<n;i++) a[i]=br.nextInt(); Arrays.sort(a); int ...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
823438f6f9c7524d5f0a9b7a7dc69ff6
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.*; public class C { public static void main(String[] args) { Scanner s = new Scanner(System.in); HashSet<Integer> set = new HashSet<Integer>(); int n = s.nextInt(); int m = s.nextInt(); for(int i=0; i<n; i++) set.add(s.nextInt()); int count = 0; Vector<Integer> ...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
11ed940e2eb7eaa5e9a37c0036016c35
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.*; import java.io.*; public class CF_C { static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static void newST() throws IOException {st = new StringTokenizer(in.readLine());} static int stInt() {return Integer.parseInt(st.nextToken());} sta...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
57999118f540865d848da0c0b7d47524
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static int mod = (int) 1e9 + 7; static int MAX = (int) 1e7; public static void main(String[] args) { FasterScanner s = new FasterScanner(); PrintWriter out = new PrintWriter(System.out); int test = 1; testloop: while (test-- ...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
8b2d9c53ffaa210d3e35206b1e2abcc5
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.lang.StringBuilder; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; import java.util.Collections; import java.util.Scanner; public class TESTer { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt()...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
334b0a8e4313985862af05c25ad1b9d5
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String[] args) throws IOException { FS input = new FS(System.in); int n = input.nextInt(); int m = input.nextInt(); int M = m; Set<Integer> owns = new HashSet<Integer>(); for(int i=0; i<n; i++) owns.add(input.nextInt())...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
43428b0c5608eff94c4729aa5cb479b0
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.*; import java.util.*; /** * * @author ehab */ public class JavaApplication7 { /** * @param args the command line arguments */ static Integer ar [] ; static boolean binar(int k) { int min = 0 ; int max = ar.length - 1 ; int mid ; while...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
93c15c8c9688946047626d15927c6f7d
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collectio...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
0460f00781ebeb8a8de12d7103e1623a
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Codef{ public static void main(String[] args) throws IOException{ BufferedReader vod=new BufferedReader(new InputStreamReader(System.in)); ...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
06c04593bae2ce267be8263a601b7a40
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.*; import java.io.*; public class R346_2_C { public static void main(String[] args) throws Exception{ Scan in = new Scan(); StringBuilder out = new StringBuilder(); int n = in.nextInt(); int m = in.nextInt(); Integer[] a = new Integer[n+1]; a[0] = 0; for (int i = 1; i <= n; i+...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
8b11ebda4ab3c3b3d9119508607cd18a
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); Set<Integer> set = new HashSet<Integer>(); int a = in.nextInt(); int b =...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
7b55453f0ad06fc7542000512e406cbf
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashSet; import java.util.StringTokenizer; public class TanyaAndToys { public static void main(String[] args) { InputReader...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
8ddd3d09e8521c025bc453d21ec76514
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.*; public class c { static Scanner in=new Scanner(System.in); public static void main(String[] args) { int n=in.nextInt(),m=in.nextInt(),c=0; Set<Integer> set=new HashSet<Integer>(); for(int i=0;i<n;i++) { Integer temp=in.nextInt(); set.add(temp); } Integer po=0; ...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
290a23cd25262ea9ca72c1828bfd0db4
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
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.StringTokenizer; import java.util.TreeSet; public class C { static StringTokenizer s...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
5b700d48146b8b56f37d64928785f616
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.*; import java.io.*; public class C659 { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); } Arrays.sort(a); int ans...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
92d43bacd92dba744ae51e889a4498f1
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.*; public class C { public static void main(String[] args) { Scanner qwe = new Scanner(System.in); int n = qwe.nextInt(); int m = qwe.nextInt(); boolean[] bought = new boolean[150000]; for(int i =0; i < n; i++){ int next = qwe.nextInt(); if(next < bought.length) bought[next] =...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
cc7161bb81eaec50631bdbdd917cdaa3
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Test { public static void main(String args[] ) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); String[] str=line.split(...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
975106a74050767f36d184810187710a
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.*; import java.util.*; public class Main { void solve() throws Exception { int n = nextInt(); int m = nextInt(); Set<Integer> set = new TreeSet<>(); for (int i = 0; i < n; i++) set.add(nextInt()); int sum = 0; List<Integer> ans = new ArrayList<>();...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
f6520b64f6d1ffb5a05c7b141a2649f7
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n, m; n = in.nextInt(); m = in.nextInt(); int[] has = new int[n+2]; for (int i = 0; i < n; i++) has[i] = in.nextInt(); ...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
9ec4dc6b631de03d15b47e6c735e5a83
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.Scanner; import java.util.Arrays; import java.util.List; import java.util.ArrayList; public class Main { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int N = scan.nextInt(), M = scan.nextInt(); int[] A = new int[N]; for(int i = 0; i < N; i++){ ...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
6d5b69b326001374afa47ee3e5b3db40
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.*; import java.util.*; public class c659 { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); String[] asdf = f.readLine().split(" "); int n = Integer.parseInt(asdf[0]); int m = Integer.parseInt(asdf[1]); asdf =...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
34895774965260821da37e3cf31e5ffe
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
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; public class Main { public static int arre[]; public static void main(String[] args) throws IOException{ BufferedReader cin=new Bu...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
d37f5189314a82140b49fdf22c37cd13
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
/* Andy Rock * March 30, 2016 * * Codeforces Round #346 (Div. 2): C */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class C { public static void main(String[] args) throws ...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
f0f0c67799ee0270fe2551a1374ef849
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.ArrayList; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int total=s.nextInt(); HashMap<Integer,Integer> hm=new HashMap<Integer,Integer>(); for(int i=0;i<n;i++) { hm....
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
c30296e556786af869d35bd18693de9b
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.List; public class P659C { InputStream is; PrintWriter out; // String INPUT = "3...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
e56e432f27bab0f55745bfd650c03acf
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.PrintStream; import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class C { private static Scanner in = new Scanner(System.in); private static PrintStream out = System.out; public static void main(String[] args) { int n = in.nextInt(); in...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
38ec8ef93ccefdf3480335059721c91c
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Palindrome { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] arr=new int[n]; int m=sc.nextInt(); Set<Integer> set=new HashSet<>(); Set...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
b0573430c36423e618b95ae2889d221b
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.util.*; public class Main { public static int arrLimit =31250000; public static void main(String[] args) { int[] status = new int[arrLimit]; ArrayList<Integer> ans = new ArrayList<Integer>(); Scanner scanner = new Scanner(System.in); int n = scanner.nex...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
fd336a69ac92f3d53c62752859dfb1d6
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.awt.Point; import java.awt.geom.Line2D; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.security.GuardedObject; im...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
48c3c8783175dab451c1173e1ff206c2
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.IOException; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class TestAC { public static void main(String[] args) throws IOException { Scanner input = new Scanner(System.in); int n = input.nextInt(); Set<Integer> set = new HashSet<>(); int k = input.nextInt(...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
3318e36e75b4f2f3aee189a656b8b92a
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.IOException; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class TestAC { public static void main(String[] args) throws IOException { Scanner input = new Scanner(System.in); int n = input.nextInt(); Set<Integer> set = new HashSet<>(); int k = input.nextInt(...
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
093e24e8848812fcd53f050ee5a96daa
train_002.jsonl
1459353900
In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's ...
256 megabytes
import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util....
Java
["3 7\n1 3 4", "4 14\n4 6 12 8"]
1 second
["2\n2 5", "4\n7 2 3 1"]
NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.
Java 7
standard input
[ "implementation", "greedy" ]
0318d4d5ea3425bf6506edeb1026f597
The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya alread...
1,200
In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integer...
standard output
PASSED
ebb121c668de71626a4e534a3d867941
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; import static java.lang.System.*; public class D { public static void main(String[]args){ InputReader sc = new InputReader(System.in); PrintWriter pw =new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); ...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
7f23235937ede17c4f69ae1d72adae5d
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; import java.util.logging.Logger; public class Main { public static void main(String[] args){ PrintWriter out = new PrintWriter(System.out); InputRead...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
29c7738eb8ea3b4bb80facbffc6ed64b
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.ArrayList; import java.util.List; public class CE85D { public static void main(String[] args) throws NumberFormatException, IOException { FastReader sc=new FastReader(); ...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
69677cd151a5d79310ad59dacfa3e60d
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
// Problem : D. Minimum Euler Cycle // Contest : Educational Codeforces Round 85 (Rated for Div. 2) // URL : https://codeforces.com/contest/1334/problem/D // Memory Limit : 256 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) import java.io.*; import java.util.*; public class...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
f00b6e5d0c25bb97a12fa4c6338b51c8
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; public class Graph { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataIn...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
43173f84cc3096879f1c3ebd061793f4
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
/* *created by Kraken on 02-05-2020 at 14:27 */ //package com.kraken.cf.practice; import java.util.*; import java.io.*; public class D1334 { public static void main(String[] args) { FastReader sc = new FastReader(); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); long l = sc...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
7bd3e6e0646487e948b48cbb53e720c7
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
import java.util.*; import java.io.*; public class D1334 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); long l = sc.nextLong(), r = sc.nextLong(...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
40ff4028d137ccb91ad679ffb9b19734
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
/* D A R K L _ _ O R D D A K / | | \ L O R D A R _ / | | \ _ K L O R D A R K _ / | _ | \ _ L ...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
397f59f149dd9c8c32b9efa054133e21
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
import java.util.Scanner; public class ProblemD { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int t = s.nextInt(); for(int a=0;a<t;a++) { int n = s.nextInt(); long l = s.nextLong(); long r = s.nextLong(); long[] arr = n...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
0ad39a6ee50ca21d9aa279c30798eb6d
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class ProblemD { public static void main(String[] args) { // TODO Auto-generated method stub FastReader s = new FastReader(); PrintWriter out = ne...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
bc6a964da99972378878c08fd9367f52
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelp...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
ecce6e58d229fd3c1bc4ca0174586e3c
train_002.jsonl
1586529300
You are given a complete directed graph $$$K_n$$$ with $$$n$$$ vertices: each pair of vertices $$$u \neq v$$$ in $$$K_n$$$ have both directed edges $$$(u, v)$$$ and $$$(v, u)$$$; there are no self-loops.You should find such a cycle in $$$K_n$$$ that visits every directed edge exactly once (allowing for revisiting verti...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; /** * Built using CHelper plug-in * Actual solution is at the top */ public class MinimumEulerCycle { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out;...
Java
["3\n2 1 3\n3 3 6\n99995 9998900031 9998900031"]
2 seconds
["1 2 1 \n1 3 2 3 \n1"]
NoteIn the second test case, the lexicographically minimum cycle looks like: $$$1, 2, 1, 3, 2, 3, 1$$$.In the third test case, it's quite obvious that the cycle should start and end in vertex $$$1$$$.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "graphs" ]
afb43928545743b497b1a9975768f8e5
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. The first and only line of each test case contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$2 \le n \le 10^5$$$, $$$1 \le l \le r \le n(n - 1) + 1$$$, $$$r ...
1,800
For each test case print the segment $$$v_l, v_{l + 1}, \dots, v_r$$$ of the lexicographically smallest cycle that visits every edge exactly once.
standard output
PASSED
04ab892e568189c6edc6a10a7d1e012f
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.util.Scanner; /* * 输入n个字符串 * 记将字符串的第一个字符移到字符串的最后为一步操作 * 输出最少的步数使得n个字符串相同,无解输出-1 * */ public class MikeAndStrings { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int min = 1000000; int flag = 0; String str[] = new String[n]; fo...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
ee4dc89699e18c4ea21f556f8a045dc9
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.util.Scanner; /* * 输入n个字符串 * 记将字符串的第一个字符移到字符串的最后为一步操作 * 输出最少的步数使得n个字符串相同,无解输出-1 * */ public class MikeAndStrings { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int min = 1000000; boolean flag = false; String str[] = new String[...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
782fb2fb7d467d716cff3c02de84b064
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.util.*; import java.util.stream.*; import java.io.*; import java.math.*; import java.awt.geom.*; public class Main { public static final BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); public static final PrintWriter outWriter = new PrintWriter(System.out); public static ...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
80d18fde32e63c19e5826ce008bc1720
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
//package ap; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class one { //static HashMap<Integer,Integer> po[]=new HashMap[25000]; //static int mod= 1000000007; //static int val[]=new int[12501]; public static void main(String[] args) { InputReade...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
349de69e53621c9e0aedbdb684d0b974
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.util.*; public class Main { public static InputReader in; public static PrintWriter pw; public static void main(String args[]) { new Thread(null, new Runnable()...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
05e4dacd9260fe24c98e0efa9b5d0a21
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author msagimbekov */ publi...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
8150976a405a91dcf5f83bd73b9d0bd9
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; ...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
1510426db33f8c6d3f60b74f05155c4b
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.util.*; public class MikeAndStrings { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt();scan.nextLine(); String[] s=new String[n]; for(int i=0;i<n;i++) s[i]=scan.nextLine(); int res=0, min=(int)1e9; for(int i=0;i<n;i++) { res=-1; for(int j...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
14cfd254d0f67e1056cb8cceaabe9c79
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import javafx.util.Pair; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
6ec942a8dab82f9065e0a12c17cd56b7
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.io.*; import java.util.*; public class MikeAndStrings { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // int test = Integer.parseInt(br.readLine().trim()); // while(test --> 0) { ...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
d973ed5e03d5d96f5684efaf58d26362
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.util.*; public class MikeAndStrings { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String[] strings = new String[n]; for (int i = 0; i < n; i++) { strings[i] = in.next(); } int k = strings...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
106df38f234b0751e7fdc51908703dcc
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
/* / フフ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ム / )\⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ Y (⠀⠀| ( ͡° ͜ʖ ͡°)⠀⌒(⠀ ノ (⠀ ノ⌒ Y ⌒ヽ-く __/ | _⠀。ノ| ノ。 |/ (⠀ー '_人`ー ノ ⠀|\  ̄ _人'彡ノ ⠀ )\⠀⠀ 。⠀⠀ / ⠀⠀(\⠀ #⠀ / ⠀/⠀⠀⠀/ὣ====================D- /⠀⠀⠀/⠀ \ \⠀⠀\ ( (⠀)⠀⠀⠀⠀ ) ).⠀) (⠀⠀)⠀⠀⠀⠀⠀( | / |⠀ /⠀⠀⠀⠀⠀⠀ | / [_] ⠀⠀⠀⠀⠀[___] */ // Main Code at th...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
f8ebd2d9cedd544c5cc538478970e75f
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.io.*; import java.lang.Math; import java.util.*; public class stt { public static int norot(String str1,String str2) {int ans=0; boolean flag=true; for(int q=0;q<str1.length();q++) for(int r=0;r<str1.length();r++) { if(str1.charAt(r)!=str2.charAt((q+r)%str1.length()...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
2ff49b721c8e5e715ee39dbb5f5fd8fb
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.util.Scanner; public class Sub { public static void main(String[] args) { int count1=50*50; Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); String[] s = new String[n]; for (int i = 0; i < n; i++) { s[i] = scanner.next(); ...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
f1c5ee24347731885e8aae97dbc7821a
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class MikeAndStrings { public static FastScanner in = new FastScanner(System.in); public static class FastScanner { public BufferedReader reader; public StringTokenizer tokenizer; public FastScanner(InputStream i) { reader = new BufferedReader(ne...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
70b922a4136dec4d17828b5482fc92fd
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.io.*; import java.util.*; /** * * @author akashvermaofskt * Coding is love <3! */ public class MikeAndStrings { public static void main(String args[]) { try { int n=nextInt(); String A[]=new String[n]; for (int i = 0; i < n; i++) { A[...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
8892e46013630fbb2dad127019e19e8d
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class MikeAndStrings implements Closeable { private InputReader in = new InputReader(System.in); ...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
be83864f9b085fe0df509d4e7c72d35b
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.util.*; import java.io.*; public class Mikeandstrings { /************************ SOLUTION STARTS HERE ************************/ static HashSet<String> getCyclicRotation(String str) { HashSet<String> set = new HashSet<>(); for(int i=str.length() - 1;i >= ...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output
PASSED
adae8448591812b37ffd6468efe18cfc
train_002.jsonl
1492785300
Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can transform it into the string "oolmikec".Now Mike asks himself: what i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in...
Java
["4\nxzzwo\nzwoxz\nzzwox\nxzzwo", "2\nmolzv\nlzvmo", "3\nkc\nkc\nkc", "3\naa\naa\nab"]
2 seconds
["5", "2", "0", "-1"]
NoteIn the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".
Java 8
standard input
[ "dp", "brute force", "strings" ]
a3a7515219ebb0154218ee3520e20d75
The first line contains integer n (1 ≤ n ≤ 50) — the number of strings. This is followed by n lines which contain a string each. The i-th line corresponding to string si. Lengths of strings are equal. Lengths of each string is positive and don't exceed 50.
1,300
Print the minimal number of moves Mike needs in order to make all the strings equal or print  - 1 if there is no solution.
standard output