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
9c561f9b843245f9e8b4f17d75339382
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
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.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import sta...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
8541af9edd00a5d6cab9d3bed68a3260
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.util.*; import java.io.*; public class MishkaandInterestingsum { /************************ SOLUTION STARTS HERE ***********************/ static int BIT[]; static int N; static void update(int idx,int val){ for(;idx <= N;idx += (idx & ((~idx) + 1))) BIT[idx] ^= val; } static int xorSum(int i...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
2b5b2820345ad5181d2d468ebf7b5d23
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
// package codeforces.cf3xx.cf365.div2; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; /** * Created by hama_du on 2016/08/06. */ public class D { public static ...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
306a31f9cfa02cb1b4cb5d66457bbf9a
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
//package round365; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; public class D { InputStream is; PrintWriter out; String INPUT = ""; void sol...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
77860d8fa91d7b5678f6825668cc5da0
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; public class D703 { private static int[] segmentTree; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Pri...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
f1c2ffb2a6833fafd284b8831f598217
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; import java.io.*; public class Main { void solve() { int N = sc.nextInt(); int[] a = sc.nextIntArray(N); int[] sum = new int[N+1]; for (int i = 0; i < N; i++) { sum[i+1] = sum[i] ^ a[i]; } int Q = sc.nextInt(); i...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
40dd433c6e19793b7cdc16df14d81299
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.io.IOException; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.InputMismatchException; public class MishkaAndInterestingSum { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt();...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
82f32fc5d0f92155455acee454f09431
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.io.IOException; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.InputMismatchException; public class MishkaAndInterestingSum { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt();...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
56ce8326f2615a3efecb1666b0ccd1e6
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.io.IOException; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.InputMismatchException; public class MishkaAndInterestingSum { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt();...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
30b24a17cefcfaea7b2daee046444f0a
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.io.IOException; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.InputMismatchException; public class MishkaAndInterestingSum { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt();...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
738c45b690db64b8ce06ffb00402c997
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.io.IOException; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.InputMismatchException; public class MishkaAndInterestingSum { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt();...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
a68306f3709128802b45496c4be4bfd9
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.io.*; import java.util.*; import java.util.stream.IntStream; /** * 703D */ public class MishkaSum { // static class Profiler { // List<String> mLabels = new ArrayList<>(); // List<Long> mTime = new ArrayList<>(); // // String current; // long started; // // void star...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
0f988a247687eab236809cd50cd4c645
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { void solve() throws IOException { int n = ni(); int[] a = nia(n); int m = ni(); Pair[] p = new Pair[m]; for (int...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
593096b1c3864901b94702c0613e92af
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Ta...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
14405bb7a1e91335228ca68add8b1f04
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Ta...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
16b589a37e212d9f3e780cfa5d109ab3
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.awt.*; import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.List; import static java.lang.Math.max; import static java.lang.Math.min; public class ProblemD implements Runnable{ private final static Random rnd = new Random(); // SOLUTIO...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
0f030f3fff33f0561af2a4457aff605f
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.awt.*; import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.List; import static java.lang.Math.max; import static java.lang.Math.min; public class ProblemD implements Runnable{ private final static Random rnd = new Random(); // SOLUTIO...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
7c6d3e8e9b6b025d35dbe9aa9f8c8101
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
import java.awt.*; import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.List; import static java.lang.Math.max; import static java.lang.Math.min; public class ProblemD implements Runnable{ private final static Random rnd = new Random(); // SOLUTIO...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
d887cd4033993f5e2f0cc36262fd09eb
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
256 megabytes
/* Keep solving problems. */ import java.util.*; import java.io.*; public class CFA { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; private static final long MOD = 1000L * 1000L * 1000L + 7; private static final int[] dx = {0, -1, 0, 1}; private static final int[] dy...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
abc2b7439d9a37e87996c215cd6b6556
train_003.jsonl
1470323700
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because o...
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.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import...
Java
["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5"]
3.5 seconds
["0", "0\n3\n1\n3\n2"]
NoteIn the second sample:There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.In the second query there is only integer 3 is presented even number of times — the answer is 3.In the third query only integer 1 is written down — the answer is 1.In the four...
Java 8
standard input
[ "data structures" ]
6fe09ae0980bbc59230290c7ac0bc7c3
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — array elements. The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries. Each of th...
2,100
Print m non-negative integers — the answers for the queries in the order they appear in the input.
standard output
PASSED
fa9f7a4dc8c811dae1b7af8c74f46e7a
train_003.jsonl
1335614400
In ABBYY a wonderful Smart Beaver lives. This time, he began to study history. When he read about the Roman Empire, he became interested in the life of merchants.The Roman Empire consisted of n cities numbered from 1 to n. It also had m bidirectional roads numbered from 1 to m. Each road connected two different cities....
256 megabytes
/** * Created with IntelliJ IDEA. * User: Zakhar_Voit * Date: 28.04.12 * Time: 22:10 */ import java.io.*; import java.util.*; import static java.lang.System.exit; public class B { BufferedReader in; PrintWriter out; StringTokenizer st = new StringTokenizer(""); final int INF = (int)2e9; in...
Java
["7 8\n1 2\n2 3\n3 4\n4 5\n5 6\n5 7\n3 5\n4 7\n4\n1 5\n2 4\n2 6\n4 7"]
2 seconds
["2\n1\n2\n0"]
NoteThe given sample is illustrated in the figure below. Let's describe the result for the first merchant. The merchant's warehouse is located in city 1 and his shop is in city 5. Let us note that if either road, (1, 2) or (2, 3) is destroyed, there won't be any path between cities 1 and 5 anymore. If any other road ...
Java 7
standard input
[]
184314d3aa83d48b71a95ae4b48de457
The first input line contains two integers n and m, separated by a space, n is the number of cities, and m is the number of roads in the empire. The following m lines contain pairs of integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi), separated by a space — the numbers of cities connected by the i-th road. It is guaranteed tha...
1,600
Print exactly k lines, the i-th line should contain a single integer di — the number of dinars that the i-th merchant paid.
standard output
PASSED
c49e78080f3b5fc9d7775bb8729d9d4d
train_003.jsonl
1335614400
In ABBYY a wonderful Smart Beaver lives. This time, he began to study history. When he read about the Roman Empire, he became interested in the life of merchants.The Roman Empire consisted of n cities numbered from 1 to n. It also had m bidirectional roads numbered from 1 to m. Each road connected two different cities....
256 megabytes
import static java.util.Arrays.deepToString; import java.io.*; import java.math.*; import java.util.*; public class B { static ArrayList<Integer> cl = new ArrayList<>(), cr = new ArrayList<>(); static boolean[] used; static int timer = 0; static int[] tin, fup; static ArrayList<Integer>[] g; static Set<Long> ...
Java
["7 8\n1 2\n2 3\n3 4\n4 5\n5 6\n5 7\n3 5\n4 7\n4\n1 5\n2 4\n2 6\n4 7"]
2 seconds
["2\n1\n2\n0"]
NoteThe given sample is illustrated in the figure below. Let's describe the result for the first merchant. The merchant's warehouse is located in city 1 and his shop is in city 5. Let us note that if either road, (1, 2) or (2, 3) is destroyed, there won't be any path between cities 1 and 5 anymore. If any other road ...
Java 7
standard input
[]
184314d3aa83d48b71a95ae4b48de457
The first input line contains two integers n and m, separated by a space, n is the number of cities, and m is the number of roads in the empire. The following m lines contain pairs of integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi), separated by a space — the numbers of cities connected by the i-th road. It is guaranteed tha...
1,600
Print exactly k lines, the i-th line should contain a single integer di — the number of dinars that the i-th merchant paid.
standard output
PASSED
14220029d5b120bacfd2632e44e5bb28
train_003.jsonl
1335614400
In ABBYY a wonderful Smart Beaver lives. This time, he began to study history. When he read about the Roman Empire, he became interested in the life of merchants.The Roman Empire consisted of n cities numbered from 1 to n. It also had m bidirectional roads numbered from 1 to m. Each road connected two different cities....
256 megabytes
import java.util.*; import java.io.*; public class Solution { FastScanner in; PrintWriter out; int N, M, K, co = 0; compa[] xx; boolean[] used; city[] g; class city { ArrayList<Integer> roads; ArrayList<Integer> bridges; int comp; } class compa { ArrayList<Integer> r; ArrayList<Integer> g; in...
Java
["7 8\n1 2\n2 3\n3 4\n4 5\n5 6\n5 7\n3 5\n4 7\n4\n1 5\n2 4\n2 6\n4 7"]
2 seconds
["2\n1\n2\n0"]
NoteThe given sample is illustrated in the figure below. Let's describe the result for the first merchant. The merchant's warehouse is located in city 1 and his shop is in city 5. Let us note that if either road, (1, 2) or (2, 3) is destroyed, there won't be any path between cities 1 and 5 anymore. If any other road ...
Java 7
standard input
[]
184314d3aa83d48b71a95ae4b48de457
The first input line contains two integers n and m, separated by a space, n is the number of cities, and m is the number of roads in the empire. The following m lines contain pairs of integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi), separated by a space — the numbers of cities connected by the i-th road. It is guaranteed tha...
1,600
Print exactly k lines, the i-th line should contain a single integer di — the number of dinars that the i-th merchant paid.
standard output
PASSED
1c58f5e819fcbcf49503fff5ec90d272
train_003.jsonl
1335614400
In ABBYY a wonderful Smart Beaver lives. This time, he began to study history. When he read about the Roman Empire, he became interested in the life of merchants.The Roman Empire consisted of n cities numbered from 1 to n. It also had m bidirectional roads numbered from 1 to m. Each road connected two different cities....
256 megabytes
import java.io.*; import java.util.*; public class cf178b { public static void main(String[] args) { FastIO in = new FastIO(), out = in; int n = in.nextInt(); int m = in.nextInt(); int[] a = new int[m]; int[] b = new int[m]; Graph g = new Graph(n); for(int i=0; i<m; i++) { a[i] = i...
Java
["7 8\n1 2\n2 3\n3 4\n4 5\n5 6\n5 7\n3 5\n4 7\n4\n1 5\n2 4\n2 6\n4 7"]
2 seconds
["2\n1\n2\n0"]
NoteThe given sample is illustrated in the figure below. Let's describe the result for the first merchant. The merchant's warehouse is located in city 1 and his shop is in city 5. Let us note that if either road, (1, 2) or (2, 3) is destroyed, there won't be any path between cities 1 and 5 anymore. If any other road ...
Java 7
standard input
[]
184314d3aa83d48b71a95ae4b48de457
The first input line contains two integers n and m, separated by a space, n is the number of cities, and m is the number of roads in the empire. The following m lines contain pairs of integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi), separated by a space — the numbers of cities connected by the i-th road. It is guaranteed tha...
1,600
Print exactly k lines, the i-th line should contain a single integer di — the number of dinars that the i-th merchant paid.
standard output
PASSED
5ad959acd2f754117150b71a6323e46c
train_003.jsonl
1335614400
In ABBYY a wonderful Smart Beaver lives. This time, he began to study history. When he read about the Roman Empire, he became interested in the life of merchants.The Roman Empire consisted of n cities numbered from 1 to n. It also had m bidirectional roads numbered from 1 to m. Each road connected two different cities....
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; public class Solution { BufferedReader in; PrintWriter out; StringTokenizer st; String nextToken() throws Exception { while (st ==...
Java
["7 8\n1 2\n2 3\n3 4\n4 5\n5 6\n5 7\n3 5\n4 7\n4\n1 5\n2 4\n2 6\n4 7"]
2 seconds
["2\n1\n2\n0"]
NoteThe given sample is illustrated in the figure below. Let's describe the result for the first merchant. The merchant's warehouse is located in city 1 and his shop is in city 5. Let us note that if either road, (1, 2) or (2, 3) is destroyed, there won't be any path between cities 1 and 5 anymore. If any other road ...
Java 7
standard input
[]
184314d3aa83d48b71a95ae4b48de457
The first input line contains two integers n and m, separated by a space, n is the number of cities, and m is the number of roads in the empire. The following m lines contain pairs of integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi), separated by a space — the numbers of cities connected by the i-th road. It is guaranteed tha...
1,600
Print exactly k lines, the i-th line should contain a single integer di — the number of dinars that the i-th merchant paid.
standard output
PASSED
eb833c9abd7313a5c60396ac3854f016
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.util.function.BinaryOperator; public class Main { static PrintWriter out; static Inp...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
b471e31c384fe75298486a423ce31603
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; public class E { private static int n; private static long[] dp; private int[][] b; public static void main(String[] args) { Inp...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
039192026aaa298ff1f27bfd21588866
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.io.*; import java.util.*; public class CF598E { private static final long MAX_VALUE = 10L * 200000L * 1000000000L; private static int n; private static Member[] members; private static long[] dp = new long[200005]; private static int[] path = new int[200005]; public static void main(String[] args...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
13104b0aee9b500477c64d2d8fb96b69
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.io.*; import java.util.*; @SuppressWarnings("unused") public class Main { private FastScanner in; private PrintWriter out; final int MOD = (int)1e9+7; long ceil(long a, long b){return (a + b - 1) / b;} long gcd(long a, long b){return b == 0 ? a : gcd(b, a % b);} long lcm(long a, lon...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
51e2396ec0d8ac07ceb0b8f090dfc46c
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.io.*; import java.util.*; @SuppressWarnings("unused") public class Main { private FastScanner in; private PrintWriter out; final int MOD = (int)1e9+7; long ceil(long a, long b){return (a + b - 1) / b;} long gcd(long a, long b){return b == 0 ? a : gcd(b, a % b);} long lcm(long a, lon...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
4616bddf7092bae6a5ae4ad96623681f
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static int log(int x){ int c =0; while(x>0){ x/=2; c++; } c--; return c; } static int pow(int a, int b){ int l =1; for(int i=0; i<b; i++){ l*=a; ...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
fb0c858a9eeb3bc20e5f34cd2d7f8be1
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.io.*; import java.util.*; public class Main { static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); // static int oo = (int)1e9; static long oo = (long)1e15; static int mod = 1_000_000_007; static int[] di = {1, 0, 0, -1}; static int[] dj...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
1f7543fca02f1dd49bea523eab69594b
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String ar[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); String s1[]=br.readLine().split(" ");...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
3f004bae909721cc05093d465b29485c
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStream; /** * Built using CHelper...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
d5d5a301a7b8bf87ae91ab8ab1d12bd4
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.Comparator; import java.util.Collec...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
5ecffe7dd49acff384b79609150c8fa1
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.awt.event.MouseAdapter; import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) throws Exception { new Main().run(); } static int groups = 0; static int[] fa; static int[] sz; ...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
bd155df011a24ac922d964a76d06e494
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ public static Integer INT(String s) { return Integer.parseInt(s); } public static Long LONG(String s) { return Long.parseLong(s); } static int mod=1_000_000_007, oo=Integer.MAX_VALUE, _oo=Integer.MAX_VALUE; //====================================...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
687b5104abb8e96e24dd983be3a680c6
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; public class E1256 { static Pair[] arr; static int[] trace; static int[][] dp; static int dp(int idx, int size) { int max = 0; if (idx == arr.length) return dp[idx][size]= 0; if (dp[idx][size] != -1) return dp[idx][size]; if (idx + 2 < arr.l...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
35f836760f86c56ab85cdda7f87a359d
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static final int UNCALC = -1; static final long INF = (long) 1e15; static long[][] memo; static int n; static Pair[] a; static int teams; static int[] ans; public static void main(String[] ...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
90bd2acecc567a031c888ef0fe1a4da3
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.math.*; import java.io.*; import java.util.*; import java.awt.*; public class CP { public static void main(String[] args) throws Exception { /*new Thread(null, new Runnable() { @Override public void run() { try { new Solver().solve();...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
58d179a51f09441ceb7def647dccad89
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
/** * @author derrick20 */ import java.io.*; import java.util.*; public class YetAnotherDivisionSimple implements Runnable { public static void main(String[] args) throws Exception { new Thread(null, new YetAnotherDivisionSimple(), ": )", 1 << 28).start(); } public void run() { FastScann...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
52a39966d8afc4588c984b226f9e8aee
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
/** * @author derrick20 */ import java.io.*; import java.util.*; public class YetAnotherDivisionIntoTeam implements Runnable { public static void main(String[] args) throws Exception { new Thread(null, new YetAnotherDivisionIntoTeam(), ": )", 1 << 28).start(); } public void run() { FastS...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
ee870fb11aa6cdfd40c48933ebc7c0a4
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.awt.Point; import java.io.File; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class thing { public static void main(String[] args) throws FileNotFoundException { //Scanner in = new Scanner(new File("template.in")); Scanner...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
acf7d44b355d65f4bf8f6e3c45e94d1e
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.io.*; import java.util.*; public class Main { private static void execute(ContestReader reader, PrintWriter out) { int n = reader.nextInt(); int[] as = reader.nextIntArray(n); for (String line : new Solver(n, as).solve()) { out.println(line); } } public static void main(Strin...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
7dc31c9bd6ff0c09b5e8e351d94400d5
train_003.jsonl
1572873300
There are $$$n$$$ students at your university. The programming skill of the $$$i$$$-th student is $$$a_i$$$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $$$2 \cdot 10^5$$$ students ready for the finals!Each team should c...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStream; ...
Java
["5\n1 1 3 4 2", "6\n1 5 12 13 2 15", "10\n1 2 5 129 185 581 1041 1909 1580 8150"]
2 seconds
["3 1\n1 1 1 1 1", "7 2\n2 2 1 1 2 1", "7486 3\n3 3 3 2 2 2 2 1 1 1"]
NoteIn the first example, there is only one team with skills $$$[1, 1, 2, 3, 4]$$$ so the answer is $$$3$$$. It can be shown that you cannot achieve a better answer.In the second example, there are two teams with skills $$$[1, 2, 5]$$$ and $$$[12, 13, 15]$$$ so the answer is $$$4 + 3 = 7$$$.In the third example, there ...
Java 8
standard input
[ "dp", "sortings", "greedy" ]
9ff029199394c3fa4ced7c65b2827b6c
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of students. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the programming skill of the $$$i$$$-th student.
2,000
In the first line print two integers $$$res$$$ and $$$k$$$ — the minimum total diversity of the division of students and the number of teams in your division, correspondingly. In the second line print $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le k$$$), where $$$t_i$$$ is the number of team to which the...
standard output
PASSED
f244e65c62c3d2dbce812551bd165ccb
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
/*import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class KefaandDishes { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); new KefaandDishes().solve(in,out); in.close(); out.close(); } int N, M...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
b11359e38377f07e14e51c906017c441
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.*; import java.util.*; public class Abc { static int n, m, k; static long a[]; static long dp[][]; static long raise[][]; public static void main(String[] args) throws Exception { FastReader sc = new FastReader(); n = sc.nextInt(); m = sc.nextInt(); k...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
72e2eaafa44b88daf74f86ee9bd169c4
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Kefa_And_Dishes { static long [] nums; static long [] [] bonus; static int total; static long [][] memo; public static void main(String[] args)throws Throwable { BufferedReade...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
147ef9a761c57eaf8c47e0b881822244
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; import java.io.*; public class codeforces { static class Student{ int x,y;//z; Student(int x,int...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
a67f53946c73a2230c2d849265d0fe79
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.util.Scanner; public class Bitmask { static int arr[]; static int bonus [][]; static long dp[][]; static long res = -1; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt(); arr = new int[n]; bonus = new int[n...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
fec1599d2587657eb77c97566e4e36b8
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.awt.Point; import java.io.*; import java.io.IOException; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; public class Tests { static Scanner in = new Scanner(); static PrintWriter out = new PrintWriter(System.out); static int n, m, k; static int ...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
a3cbabeccecaed940017f9d2cc7f9905
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces{ static int[][] satisfaction; static int[] dishes; static long[][] memo; static int n, m; static long INF = (long) -1e16; static long dp(int msk, int last, int idx){ if(idx == m){ return 0; } if(...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
b54602f6df0687fb79041ee1878b3847
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.util.Scanner; public class Bluda { public static int getOnesAmount(int num) { int res = 0; while(num != 0) { if(num % 2 != 0) ++res; num = num / 2; } return res; } public static void main(String[] args) { Scanner sc = new Scanner...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
7f8fd091185e8ebedb28bcfd48a8c244
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.awt.List; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.LinkedList; import java.util.StringTokenizer; public class kefaanddishes { static long memo[][]; static int dishes[][]; static int[] sat; static int N, M; s...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
90696dba18b54c8e43c30b7d4e0a5b64
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class dishes { static int []dish; static int [][] pri; static long [][]memo; static int n,m; static long dp(int mask,int next){ if(Integer.bitCount(mask)==m){ // System.out.println(Integer.bitCount(mask)); return 0; } if(memo[next][mask...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
1098e11a6adf3ef4a87d879bff96dd08
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; import java.lang.*; import static java.lang.Math.*; public class Main implements Runnable { public static void main(String[] args) { new Thread(null, new Main(), "Check2", 1 << 28).start();// to increse stack size in java } void ...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
98e7c840ef5d949222744ab280d71e01
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.BufferedInputStream; import java.util.Arrays; import java.util.Scanner; /* mem[x][bitMask] = The best satisfaction you can get from now on when you start with dish 'x' and took dishes in 'bitMask' already. */ public class D { static long[] sat; static long[][] bonus; static lo...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
2db7cc268a28e6653ec9f777e59daa83
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStream; /** * Built using CHelper...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
aace9ac8797025b30b96d6acb96a6edb
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
6759cb8b1a8b85188199c34d70fc462f
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class D { static int n; static int m;; static int k; static int sat[]; static int g[][]; public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); n =...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
38060e0cb95882a573d013bb82adfb05
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import javafx.scene.layout.Priority; import java.io.*; import java.util.*; public class D { static long[][] dp; static Edge[][] adj; static long[] a; static int n, max; public static void main(String[] args) { FastScannerD fs = new FastScannerD(); PrintWriter out = new PrintWrite...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
8e3824cb78e7facdd9a0cd44e60d80b6
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.util.LinkedList; import java.util.Scanner; /** * 状态压缩dp * 少于1000次输入,用Scanner */ public class Main { static int n,m,k; static int[] a; static int[][] val; static long[][] dp; static long max; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); m = s...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
bf4965cc24b061f1257084a4aeac372d
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.IOException; import java.util.ArrayList; import java.util.InputMismatchException; public class KefaAndDishes { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt(); int M = sc.nextInt(); int K = sc.nextInt(); ...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
cad5286a9977ae742282c418676b1ab8
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** What do you think? What do you think? 1st on Billboard, what do you think of it Next is a Grammy, what do you think of it However you think, I’m sorry, but shit, I have no fucking inte...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
9d552a00e76a5fa7ae2b34e376f09d1c
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.stream.IntStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Wri...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
2cd4f3e6f9b8d9734770626e297822e2
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.util.*; import java.util.concurrent.ThreadLocalRandom; import java.io.*; public class Kefa { static int n; static int[] dishSat; static int[][] bonus; static long[][]memo; public static void main(String[] args) throws NumberFormatException, IOException, InterruptedException { Scanner sc = new Scanne...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
e6c4e0703a6265284a37a001e28c8618
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.BufferedReader; public class Main{ static int[][] rules; static int[] val; static long[][] memo; static int n; static in...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
0e18294d9e3ba21510de4ba09c3907ef
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class KefaAndDishes { static class STDIN { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; String next() throws Exception { while (...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
1976c156e450e0d54e51b88d5dbf189d
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class KefaAndDishes { static int n, m, k; static long[][] dp, cost; static int[] hap; public static void main(String[] args) { Scanner scan = new Scanner(System.in); n = scan.nextInt(); m = scan.nextInt(); k = scan.nextInt(); hap = new int[n]; ...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
da50612c1a29fa19da975c2eeef3fdb2
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class KefaAndDishes { static class STDIN { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; String next() throws Exception { while (...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
caca7055c5750b9a4ee3f44ed603b17d
train_003.jsonl
1442939400
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfactio...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class D580 { static int m, n, k; static int satis[][]; static int dishes[]; static long memo[][]; public static void main(String[] args) throws IOException, InterruptedException { Scanner sc = new Scanner(System.in); PrintWri...
Java
["2 2 1\n1 1\n2 1 1", "4 3 2\n1 2 3 4\n2 1 5\n3 4 2"]
2 seconds
["3", "12"]
NoteIn the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we ...
Java 8
standard input
[ "dp", "bitmasks" ]
5b881f1cd74b17358b954299c2742bdf
The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules. The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisf...
1,800
In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.
standard output
PASSED
4815880ff04a6696166823a5fc0c2507
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.*; import java.util.*; public class Main { static ArrayList<Integer> adj_lst[]; static boolean vis[]; public static void main(String args[]){ Scanner input=new Scanner(System.in); //No of nodes int n=input.nextInt(); boolean arr[][]=new boolean[n][26]; ...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
45a4e871419cda6a1c98c30103bc9a56
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args){ InputStream inputstream; OutputStream outputstream; inputstream = System.in; outputstream = System.out; InputReader in = new InputReader(inputstream); PrintWriter out =...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
b1675ad9c1736150b7d626ef4701a52e
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Set; public class SecretPasswords { InputStream is; PrintWriter pw; String IN...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
bf39dceae93830096045107ecd706cd5
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.*; import java.util.*; public class template { public static void main(String[] args) throws IOException { FastReader scan = new FastReader(); //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("radio.out"))); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStrea...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
26150de986dea37848cab6cf4d13ab96
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.*; import java.util.*; import java.util.Map.Entry; import javax.swing.text.InternationalFormatter; import java.math.*; public class temp1 { public static PrintWriter out; static int[] a; static int[] b; static StringBuilder sb = new StringBuilder(); static int ans = 0; public static void mai...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
e8d7fdf9d6db4ee09ea372c6259649df
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; public class Main { static final int INF = (int) (1e9 + 10); static final int MOD = (int) (1e9 + 7); // static final int N = (int) (4e5 + 5); // static ArrayList<Integer>[] graph; // static boolean visited[]; // st...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
fcf7ba5dcb0259cd060746c28c2dbcde
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Vector; import java.util.Scanner; import java.util.Stack; import java.util.ArrayList; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Kraken7 */ public cl...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
1614f999163bca8d5375ece255cf77b7
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class SecretPasswords { public static class DSU{ int size = 0; DSU par = null; boolean counted = false; } public static DSU findSet(DSU dsu){ ...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
031fd295680d00fa876e8e78d6bd9a5d
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.*; import java.util.*; import static java.util.Collections.*; import static java.lang.Math.*; @SuppressWarnings("unchecked") public class D_Secret_Passwords { public static PrintWriter out; public static InputReader in; public static int[] root, sizes; public static void main(String[] ar...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
15e8efc425082dd4a504951e49095121
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.*;import java.io.*;import java.math.*; public class Main { static int find_par(int n){ if(par[n]==n) return n; return (par[n]=find_par(par[n])); } static void union(int a,int b){ int root1=find_par(a),root2=find_par(b); if(root1==root2) return; if(sz[root1]<sz[root2]){ par[r...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
ddc8f541fa38fa018a2150e12e7ed1e6
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.*; import java.util.*; public class CF1263D extends PrintWriter { CF1263D() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1263D o = new CF1263D(); o.main(); o.flush(); } static final int A = 26; int[] dsu; int find(int i) { return d...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
bebe7924b1f82f5fe2a36c1d2461dada
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class D{ static ArrayList<ArrayList<Integer>> g; static ArrayList<Boolean> vis; static void dfs(int i){ if (vis.get(i)) return; vis.set(i, true); for (int j : g.get(i)) dfs(j); } public static void main (String[]...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
8e251321b24fb1e77f1ec17eb7ac3630
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { MScanner sc = new MScanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n=sc.nextInt(); N=n+26; p = new int[numSets = N]; rank = new int[N]; setSize = new int[N]; for (...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
6ca089d199e79280313d5db165cad72c
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static void DFS(boolean vis[],int src,HashMap<Integer,HashSet<Integer>> link){ if(vis[src]==true){ return ; } vis[src]=true; for(int i:link.get(src)){ DFS(vis,i,link); } } public ...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
aec87b7b6a7c4c344fc30b955ac9143e
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.*; public class Main { Scanner sc = new Scanner(System.in); public Main() { int n = sc.nextInt(); sc.nextLine(); UnionFind uf = new UnionFind(26); boolean[] vis = new boolean[26]; for (int i = 0; i < n; i++) { String s = sc.nextLine(); ...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
0d07660eaf29f0b06d3d9240a71d2ee7
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; public class Hello { static int []fa = new int[200100]; static int gf(int x) { //return (x==fa[x])?x:fa[x] = gf(fa[x]); if (x == fa[x]) { return x; }...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
246b1bfcd6fadd2468d49f6fbae187e6
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class CP{ public static OutputStream out=new BufferedOutputStream(System.out); static Scanner sc=new Scanner(System.in); static long mod=1000000007l; static int INF=1000000; //nl-->neew line; //l-->line; //arp-->array print; //arpnl-->array ...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
2455ce3bbccca019fd12387fa30c2f5e
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.TreeSet; public class c { static int[] tree; static int[] size; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Inte...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
6854de02e8af613c745de5e9bc2a3032
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf1263d { static BufferedReader __in; static PrintWriter __out; static StringTokenizer input; public static void main(String[] args) throws IOException { __in = new BufferedRea...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
84f8e440cf759e4565a29c6110c87dcd
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.*; import java.io.*; public class d { public static PrintWriter out; public static void main(String[] args) throws IOException { FS sc = new FS(System.in); out = new PrintWriter(new BufferedOutputStream(System.out)); int n = sc.nextInt(); DSU d = new DSU(26); ...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
8df13094f7d43bc9537ea859802dbc19
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.*; import java.io.*; public class Main { static final int MOD_PRIME = 1000000007; public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStre...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
b2f5faa0c206492274e6567b2903fc97
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.* ; public class firstjava { static ArrayList< ArrayList<Integer> > v = new ArrayList< ArrayList<Integer> > ( ) ; static int[ ] visited = new int[ 26 ] ; public static void main ( String[ ] args ) { Scanner sc = new Scanner( System.in ) ; int T = 1 ; while( T -- != 0 ) { int n = sc.next...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
61f1da6d96f7ad6f4048caab5769fa2c
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.Scanner; import java.util.HashSet; public class SecretPasswords { public static void main(String[] args) { Scanner s = new Scanner(System.in); int wCnt = s.nextInt(); int[] cand = new int[26]; int[] next = new int[26]; int[] tmp; int candCnt = 0; ...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
8e8f32f0f32616cbff5262ff8e28b3ae
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.HashSet; import java.util.Scanner; public class SecretPasswords { static class Node{ Node parent = this; int size = 1; String s; Node(String s){ this.s = s; } } public static void main(String[] arg){ Scanner in = new Scanner(Sy...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
510c017f9ceb756aa9e153a62b870902
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class D { static boolean[] visited; static ArrayList<Integer>[] adj; public static void main(String[] args) { Scanner sc = new Scanner(System.in); String ref = "abcdefghijklmnopqrstuvwxyz"; adj= new ArrayList[26]; for(int i=0;i<26;i++) adj[i] = ne...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
8919276d08c3fb41ba8ccbe011dc679d
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
/** * sol1263D */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; public class sol1263D { public static String output = ""; static class FastReader { BufferedReader br; StringT...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
21baf7924be14b4f12a9aab40434891b
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.*; import java.io.*; public class D603 { static ArrayList<Integer> [] adj; static boolean [] visited; public static void main(String [] args) { MyScanner sc = new MyScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); Map<String, Integer> r...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
399ac86b20986851f571459594f8f887
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.util.*; import java.io.*; public class Sol { public static int[] id, size; public static int find(int p) { while (p != id[p]) { p = id[p]; } return p; } public static void union(int p, int q) { int rp = find(p); int rq = find(q); if (rp == rq) return; if...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output
PASSED
75f94b754d5ac30499d8476c6f8d2840
train_003.jsonl
1575038100
One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of $$$n$$$ passwords — strings, consists of small Latin letters.Hacker went home and started preparin...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int n = nextInt(); int arr[] = new int[26]; Arrays...
Java
["4\na\nb\nab\nd", "3\nab\nbc\nabc", "1\ncodeforces"]
1 second
["2", "1", "1"]
NoteIn the second example hacker need to use any of the passwords to access the system.
Java 11
standard input
[ "dsu", "dfs and similar", "graphs" ]
00db0111fd80ce1820da2af07a6cb8f1
The first line contain integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — number of passwords in the list. Next $$$n$$$ lines contains passwords from the list – non-empty strings $$$s_i$$$, with length at most $$$50$$$ letters. Some of the passwords may be equal. It is guaranteed that the total length of all passwords ...
1,500
In a single line print the minimal number of passwords, the use of which will allow guaranteed to access the system.
standard output