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
b73bd0a386b8cca0f70e6a33439ce75d
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int best = -50 * 100; int n = sc.nextInt(); String bestName = ""; ...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
78cdcbb2d1a41b9cf806724bb783a466
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public ...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
e0ee847ba0f7477cd1cacf95b43567df
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.*; import static java.lang.Math.*; import java.io.*; public class SolutionB { public static void main(String args[])throws IOException{ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); //Map<String, Integer> map = new HashMap<String, In...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
4b0ce9b7a47dbd985f0c33238b1000f3
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String[] args) throws IOException { new A().run(); } FastScanner in; PrintWriter out; void run() throws IOException { in = new FastScanner(System.in); out = new PrintWriter(System.out, true); solve(); out.close(); } voi...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
d96f31d691c022d9f30c5acd45d69099
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.*; public class A{ public static class Contestant implements Comparable<Contestant>{ String name; int points; public Contestant(String s, int p){ name = s; points = p; } public int compareTo(Contestant other){ re...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
64d6bce78415bc32e56a89648855f44c
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.Set; import java.util.StringTokenizer; public class RoomLeader { public static void main(String[] args) { PrintWriter pw = n...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
f814b4da6a7bda137bb8c0e405a2e300
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.Scanner; public class a74 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int tc=sc.nextInt(); int su[]=new int[tc]; String s[]=new String[tc]; int x=0; for(int i=0;i<tc;i++) { int sum=0; s[i]...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
f21254416ce03537869af2ade235baba
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); String win=new String(); int res=Integer.MIN_VALUE; for(int i=0;i<n;i++){ String t=sc.next(); int temp=sc.nextI...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
05ee78f3df940f6c2693f2d1b7538dd5
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Scanner; public class Main { class Node{ int value, nuOfC=0, done=0; List<Integer> connections; public Node(){ conn...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
091b9882017e3b4efa0688399d20aa70
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { FastReader in=new FastReader(); int n=in.nextInt(); String[]x=new String[n]; int y=0; long max=Integer.MIN_VALUE; ...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
b6a8913bf6cb530c117a6152528dff04
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String[] arr = new String[n]; String w =""; int sum =0; for ( int i = 0 ; i < n ; i++ ){ arr[i] = sc.next(); int plus = sc...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
71746963fe6dcd64e029015e1256941b
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.io.Writer; import java.math.BigInteger; import jav...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
485d32b5e35791c8236407fae9c3c7e3
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { public static BufferedReader in; public static PrintWriter out; public static StringTokenizer tok; public static void main(String args[]) throws IOException { in = new BufferedReader(new InputStreamReader(System.in))...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
af08b78959fc6471457bc5e70860efe5
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.Scanner; public class Codes { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int number = input.nextInt(); String roomLeader = new String(); int maxScore = Integer.MIN_VALUE; for (int i = 0; i < number; i++) { int su...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
da87661b188579f6fe7814bacfb94395
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.Scanner; public class SuperLukeyNumber { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int max = 0; String maxHandler = ""; int n = scanner.nextInt(); for (int i = 0; i < n; i++) { String temp = scanner.next()...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
21f647a2196457bd730f2e23ef1c4559
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.InputMismatchEx...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
06d69e204a35e38a9137c23a33170ad3
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
//package codeforces; import java.io.BufferedReader; import java.io.Closeable; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util....
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
472804468915c6ecbcdd4f9a19f104e3
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class RoomLeader { public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); int max=Integer.MIN_VALUE;...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
ac8aba9787620adb7e18a1bf92d62743
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.*; public class Sr { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); String[]arr=new String[n]; int[]p=new int[7]; int[]s=new int[n]; int[]s2=new int[n]; for (int i = 0; i < n;...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
90a92a3b5f9d9fa497cac339eb2b0ac7
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class RoomLeader { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintW...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
a6dc7d96d03f7b9cc1b987c0c32f7550
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.Scanner; public class A74 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); String answer = null; int maxPoints = Integer.MIN_VALUE; for (int n=0; n<N; n++) { String name = in.next(); ...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
e0356ebf1c5ae2b877d8ca5afb8ef749
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.Scanner; public class A_Rooms { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String line = scanner.nextLine(); int gamersCount = Integer.parseInt(line); String winner = ""; int winnerScore = Integer.MIN_VALUE; ...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
1e495390f975f088ad489a6496b18e0d
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.uti...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
9ac67ad06881e84a7af01d6d3e0be5fb
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.Arrays; import java.util.Comparator; import java.io.BufferedReader; import java.io.InputStreamReader; public class RoomLeader74A { public static void main(final String[] args) throws Exception { final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
6a4f015ad032bf89db3a4e2710f38783
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.*; public class P74A { public static void main(String [] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String winner = ""; int winner_point = Integer.MIN_VALUE; for (int i = 0; i < n; i++) { String handle = in.next(); ...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
882c11d061fead376bd43b12a1fab201
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.Scanner; public class RoomLeader { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int n = input.nextInt(); String s = ""; int max = Integer.MIN_VALUE; for(int i=0;i<n;i++){ String z = input.next(); int total = 10...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
d1a2e082e08d4cf9637373d727b803ab
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.ut...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
ac8aed4b130ee96e81003deadbb3c744
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.*; /** * https://codeforces.com/problemset/problem/74/A */ public class Problem74A { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); scanner.useDelimiter(System.lineSeparator()); int n = Integer.parseInt(scanner.next()); List<Pa...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 8
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
13993a78f296b7e645dd6ef808794439
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.util.Scanner; public class A74 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); String s; String s1 =""; int l =-100000000, n = sc.nextInt(), a = 0, b = 0, c = 0, d = 0, e = 0, p = 0, m = 0, result = 0;...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 6
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
627b56458ac0c734b60c4de663017392
train_003.jsonl
1302879600
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public...
Java
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
2 seconds
["tourist"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
Java 6
standard input
[ "implementation" ]
b9dacff0cab78595296d697d22dce5d9
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
1,000
Print on the single line the handle of the room leader.
standard output
PASSED
2e4bd648030782b8bf80a61d9bb36c6d
train_003.jsonl
1604327700
A permutation is a sequence of integers from $$$1$$$ to $$$n$$$ of length $$$n$$$ containing each number exactly once. For example, $$$[1]$$$, $$$[4, 3, 5, 1, 2]$$$, $$$[3, 2, 1]$$$ — are permutations, and $$$[1, 1]$$$, $$$[4, 3, 1]$$$, $$$[2, 3, 4]$$$ — no.Permutation $$$a$$$ is lexicographically smaller than permutat...
256 megabytes
import java.util.*; import java.io.*; public class codeforces { static long[]a; static long[]fac; public static void up(long x) { int start=Math.max(a.length-1-18, 1); TreeSet<Integer>ts=new TreeSet<Integer>(); for(int i=start;i<a.length;i++) { ts.add(i); } int r=a.length-1-start; long X=x; wh...
Java
["4 4\n1 2 4\n2 3\n1 1 2\n1 3 4"]
4 seconds
["9\n4\n6"]
NoteInitially, the permutation has the form $$$[1, 2, 3, 4]$$$. Queries processing is as follows: $$$2 + 3 + 4 = 9$$$; $$$[1, 2, 3, 4] \rightarrow [1, 2, 4, 3] \rightarrow [1, 3, 2, 4] \rightarrow [1, 3, 4, 2]$$$; $$$1 + 3 = 4$$$; $$$4 + 2 = 6$$$
Java 8
standard input
[ "two pointers", "brute force", "math" ]
d458a65b351b2ba7f9891178ef1b64a1
The first line contains two integers $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) and $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$), where $$$n$$$ — the length of the initial permutation, and $$$q$$$ — the number of queries. The next $$$q$$$ lines contain a single query of the $$$1$$$-st or $$$2$$$-nd type. The $$$1$$$-st type ...
2,400
For each query of the $$$1$$$-st type, output on a separate line one integer — the required sum.
standard output
PASSED
f7d1188ba84f0948e4ce43e2a8574de4
train_003.jsonl
1604327700
A permutation is a sequence of integers from $$$1$$$ to $$$n$$$ of length $$$n$$$ containing each number exactly once. For example, $$$[1]$$$, $$$[4, 3, 5, 1, 2]$$$, $$$[3, 2, 1]$$$ — are permutations, and $$$[1, 1]$$$, $$$[4, 3, 1]$$$, $$$[2, 3, 4]$$$ — no.Permutation $$$a$$$ is lexicographically smaller than permutat...
256 megabytes
import java.awt.*; import java.io.*; import java.util.*; import java.util.List; public class Coding { private static BufferedReader bi = new BufferedReader(new InputStreamReader(System.in)); private static BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out)); static long[] segmen...
Java
["4 4\n1 2 4\n2 3\n1 1 2\n1 3 4"]
4 seconds
["9\n4\n6"]
NoteInitially, the permutation has the form $$$[1, 2, 3, 4]$$$. Queries processing is as follows: $$$2 + 3 + 4 = 9$$$; $$$[1, 2, 3, 4] \rightarrow [1, 2, 4, 3] \rightarrow [1, 3, 2, 4] \rightarrow [1, 3, 4, 2]$$$; $$$1 + 3 = 4$$$; $$$4 + 2 = 6$$$
Java 8
standard input
[ "two pointers", "brute force", "math" ]
d458a65b351b2ba7f9891178ef1b64a1
The first line contains two integers $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) and $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$), where $$$n$$$ — the length of the initial permutation, and $$$q$$$ — the number of queries. The next $$$q$$$ lines contain a single query of the $$$1$$$-st or $$$2$$$-nd type. The $$$1$$$-st type ...
2,400
For each query of the $$$1$$$-st type, output on a separate line one integer — the required sum.
standard output
PASSED
8af259e180e96ca14d4a44803eda08e9
train_003.jsonl
1604327700
A permutation is a sequence of integers from $$$1$$$ to $$$n$$$ of length $$$n$$$ containing each number exactly once. For example, $$$[1]$$$, $$$[4, 3, 5, 1, 2]$$$, $$$[3, 2, 1]$$$ — are permutations, and $$$[1, 1]$$$, $$$[4, 3, 1]$$$, $$$[2, 3, 4]$$$ — no.Permutation $$$a$$$ is lexicographically smaller than permutat...
256 megabytes
import java.awt.*; import java.io.*; import java.util.*; import java.util.List; public class Coding { private static BufferedReader bi = new BufferedReader(new InputStreamReader(System.in)); private static BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out)); static long[] segmen...
Java
["4 4\n1 2 4\n2 3\n1 1 2\n1 3 4"]
4 seconds
["9\n4\n6"]
NoteInitially, the permutation has the form $$$[1, 2, 3, 4]$$$. Queries processing is as follows: $$$2 + 3 + 4 = 9$$$; $$$[1, 2, 3, 4] \rightarrow [1, 2, 4, 3] \rightarrow [1, 3, 2, 4] \rightarrow [1, 3, 4, 2]$$$; $$$1 + 3 = 4$$$; $$$4 + 2 = 6$$$
Java 8
standard input
[ "two pointers", "brute force", "math" ]
d458a65b351b2ba7f9891178ef1b64a1
The first line contains two integers $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) and $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$), where $$$n$$$ — the length of the initial permutation, and $$$q$$$ — the number of queries. The next $$$q$$$ lines contain a single query of the $$$1$$$-st or $$$2$$$-nd type. The $$$1$$$-st type ...
2,400
For each query of the $$$1$$$-st type, output on a separate line one integer — the required sum.
standard output
PASSED
319a37f0317763d4ff6b8ae691c9ef68
train_003.jsonl
1604327700
A permutation is a sequence of integers from $$$1$$$ to $$$n$$$ of length $$$n$$$ containing each number exactly once. For example, $$$[1]$$$, $$$[4, 3, 5, 1, 2]$$$, $$$[3, 2, 1]$$$ — are permutations, and $$$[1, 1]$$$, $$$[4, 3, 1]$$$, $$$[2, 3, 4]$$$ — no.Permutation $$$a$$$ is lexicographically smaller than permutat...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) {new Main().run();} FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ work(); out.flush(); } long mod=1000000007; long gcd(long a,long...
Java
["4 4\n1 2 4\n2 3\n1 1 2\n1 3 4"]
4 seconds
["9\n4\n6"]
NoteInitially, the permutation has the form $$$[1, 2, 3, 4]$$$. Queries processing is as follows: $$$2 + 3 + 4 = 9$$$; $$$[1, 2, 3, 4] \rightarrow [1, 2, 4, 3] \rightarrow [1, 3, 2, 4] \rightarrow [1, 3, 4, 2]$$$; $$$1 + 3 = 4$$$; $$$4 + 2 = 6$$$
Java 8
standard input
[ "two pointers", "brute force", "math" ]
d458a65b351b2ba7f9891178ef1b64a1
The first line contains two integers $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) and $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$), where $$$n$$$ — the length of the initial permutation, and $$$q$$$ — the number of queries. The next $$$q$$$ lines contain a single query of the $$$1$$$-st or $$$2$$$-nd type. The $$$1$$$-st type ...
2,400
For each query of the $$$1$$$-st type, output on a separate line one integer — the required sum.
standard output
PASSED
733872c24d9837f2ecbf95ab0875ca05
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.*; import java.util.*; public class R365B { public static void main(String[] args) throws IOException, NumberFormatException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); Scanner s = new Scanner(System.in); String[] ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
4e1d59723233ae5539f7d03ed5740722
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.*; import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; /** * Created by Алексей on 07/20/2016. */ public class IDontKnow { public static void main(String [] args){ InputStream inputStream = System.in; OutputStream outputStream = System.out; Integer readFro...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
391f663412e5e9230a51e1e2d8463304
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class _365div2Q2 { public static void main(String[] args) throws IOException { FastScanner obj = new FastScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int n = obj.nextInt(); int k = obj.nextInt(); ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
a4426512611e87d23a72d366d5a3624b
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
6859527102d9bb3971dd1e87354f1aa6
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
/* * Code Author: Jayesh Udhani * Institute : DA-IICT * 3rd year BTech ICT Student */ import java.io.*; import java.util.*; public class CF365B { private static int[] nextIntArray(InputReader in,int n) { int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=in.nextInt(); return a; } private static void sho...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
8d3322d33ad5be7f93a5120b83b91eea
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.IOException; import java.util.InputMismatchException; public class MishkaAndTrip { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt(); int K = sc.nextInt(); long[] C = new long[N]; long allSu...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
53a35cf36e9845923fae986906173d25
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.IOException; import java.util.InputMismatchException; public class MishkaAndTrip { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt(); int K = sc.nextInt(); long[] C = sc.nextLongArray(N); ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
522301c826bfa582f9d808a9c65dda7f
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.IOException; import java.util.InputMismatchException; public class MishkaAndTrip { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt(); int K = sc.nextInt(); long[] C = sc.nextLongArray(N); ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
0a1b7ec257398226ffdadf954653d2cf
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.*; import java.util.Scanner; public class Main { static void solve(Scanner in, PrintWriter out) { int number_citys = in.nextInt(); int number_capitals = in.nextInt(); int[] costs = new int[100001]; long sum_costs = 0; for (int i = 1; i <= number_citys; i++) {...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
f6a44e66a3347918aa8113e4446ab11c
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.*; import java.util.*; public class tmp1 { public static InputReader in; public static PrintWriter out; public static final int MOD = (int) (1e9 + 7); public static void main(String[] args) { in = new InputReader(System.in); out = new PrintWriter(System.out); ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
0cb8db3c56b1e85452151291ad456d93
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class B2 { /** * @param args */ public static void main(String[] args) { // TODO Auto-ge...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
066cb946d4a0ec2325b972fffc20fb8f
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.*; import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; public class Main { public static void main(String args[])throws IOException { //Algorithm1 BufferedReader obj=new BufferedReader(new InputStreamReader(System.in)); String temp1[]=obj.readLine().split(" "); int n=Integer...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
ebff3346d1b3dca0c1c084f3231f7997
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.*; import java.util.HashMap; import java.util.HashSet; import java.util.StringTokenizer; /** * Created by for on 2017-02-05. */ public class Main { public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
5ad7b263ff9c6b528ad2d595c8456a0e
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class MishaAndTrip { public static void main(String[] args) { Scanner sc = new Scanner(); int n=sc.nextInt(); int k=sc.nextInt(); int[] beauty=new int[n]; boolean[] iscapital=new boolean[n]; long sumofallbeauty=0; for(int i=0;i<n;i++) { ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
5b2bfd4292828d023a3a58479b2242b8
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class B { public static void main(String[] args) { try (Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)))) { fin...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
bfb56a5fbfddf6136b890f33c1dee6e9
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; public class B { public static void main(String[] args) { try (Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)))) { final int n = in.nextInt(), k = in.nextInt(); fi...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
9496980995f24ace22521f4d5cf8387e
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class B { public static void main(String[] args) { try (Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)))) { fin...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
041f9f002770cb42ca31f018cb6e48dc
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.InputStream; import java.util.ArrayList; import java.util.NoSuchElementException; import java.util.Scanner; public class OutputBasedSolver { public static void main(String[] args) { new OutputBasedSolver(false, System.in).solve(); } public OutputBasedSolver(boolean hasMultipleTests,...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
d0cac5bcff36f8f5c6297749792051b0
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
//package com.company; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { //new Solve(new Scanner(System.in)).runA(); new Solve(new Scanner(System.in)).runB(); } private static class Solve { Scanner sc ; pu...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
6e6b9709336eb8664a78797c6b5c8833
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.util.*; import java.io.*; public class Cheker{ public static InputReader sc; public static PrintWriter out; public static final int MOD = (int) (1e9 + 7); public static void main(String[] args){ sc=new InputReader(System.in); out=new PrintWriter(System.out); int n=sc.nextInt(); ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
6667f6d491493162d3c3ea0185d793e9
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.*; import java.util.*; public class B { static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static int nextInt() throws IOException { in.nextToken(); return (int) in.nval; } static long nextLong() throws IOException { in.nextToken(); retu...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
370dfdb5da3d7c31dce054cee0c33fc0
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; i...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
5e2814820a4ef1a7be3ca5b203767634
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { public static long sum(int [] cities, int [] capitals) { int N = cities.length; boolean [] isCapital = new boolean[N]; long res = 0; long totalBeauty = 0; ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
ba3e37b92139831d15134941224393e8
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { public static long sum(int [] cities, int [] capitals) { int N = cities.length; boolean [] isCapital = new boolean[N]; long totalBeautyCaps = 0; for(int i=0; ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
6368c687ddf3531fed8f3640f93d1c96
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class CodeForces { private final BufferedReader reader; private final PrintWriter writer; private StringTokenizer tokenizer; private void solve() { int n = nextInt(); int k = nextInt(); long c[] = new lon...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
efce02316f31a4ba6bd17d14b5ebce9d
train_003.jsonl
1470323700
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the count...
256 megabytes
import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), k = sc.nextInt(); int c[] = new int[n]; for (int i = 0; i < n; i++) { c[i] ...
Java
["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4"]
1 second
["17", "71"]
NoteThis image describes first sample case:It is easy to see that summary price is equal to 17.This image describes second sample case:It is easy to see that summary price is equal to 71.
Java 8
standard input
[ "implementation", "math" ]
bc6b8fda79c257e6c4e280d7929ed8a1
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them. The second line of the input contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 10 000) — beauty values of the cities. The third line of the input contains k disti...
1,400
Print the only integer — summary price of passing each of the roads in XXX.
standard output
PASSED
9796f18c1eb49ba315376e3e06e8a30e
train_003.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int k=input.nextInt(); if(n==1) { System.out.println(-1); System.exit(0); } int arr[...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 11
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
72da349ce1f43d13f8e4ce7367f40a7c
train_003.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
// INKO MERE CODE SE KYA DIKAAT HAIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII import java.io.*; import java.util.*; public class GPL implements Runnable { public static void main(String[] args) { new Thread(new GPL()).run(); } BufferedReader br; StringTokenizer in; PrintWriter out; public Str...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 11
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
5fd6fa2862776e7b42098cb497bb9c60
train_003.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.util.*; import java.io.*; public class Main{ static boolean[] vis; //line 74 and 91 hasElement ans pth_fnd static int MOD=1000000007; // static int[] ans; static int cnt; static long set1=0,set2=0; // public static void main(String[] args) throws IOEx...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 11
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
d51c1674223f2f2198202a7698e6b51d
train_003.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.OutputStreamWriter; import java.util.Scanner; import java.io.PrintWriter; public class test { public static void main(String[] args) { Scanner input = new Scanner(System.in); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); int n = input.nextInt(); ...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 11
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
61cfe2360e4656c9db43676c71cad94e
train_003.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.*; import java.util.*; public class GPL implements Runnable { public static void main(String[] args) { new Thread(new GPL()).run(); } BufferedReader br; StringTokenizer in; PrintWriter out; public String nextToken() throws IOException { while (in == null || !...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 11
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
2ae6177e8a81d3ad4dcbeb75aa5d02ea
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.util.*; import java.io.*; public class _0208_E_BloodCousins { static ArrayList<Integer> graph[]; static int st[], et[], arr[], time = 0, dep[], par[], sqrtN; public static class Query implements Comparable<Query>{ int l, r, val, id; public Query(int l, int r, int val, int id) { this.l = l; this...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
29f9a169483fbe786415cc90426233ec
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.io.BufferedReader; import java.util.Comparator; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Collection; import java.util.List; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.ArrayList; import java.util.StringTokenizer; im...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
6f171e45c01fd062edfaa0e441504f3d
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.io.*; import java.util.*; public class BloodCousins { public static int N; public static int D; public static int[][] par; public static int[] depth; public static boolean[] vis; public static ArrayList<Integer>[] adj; public static ArrayList<Integer>[] depths; public static int[] ti, to; publi...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
b71a995067ec0b5fbd9b14a5e5ca444b
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
//package codeforces; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import ja...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
c26b3894a4f8871a1a98bc949b11ac6e
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
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.StringTokenizer; public class D { static ArrayList<Query>[] queries; static ArrayList<Integer>...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
8116d8b5c97f7b6b6cb3e0ef731c17dd
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.*; import java.util.*; import java.util.Map.Entry; public class TestClass { private static InputStream stream; private static byte[] buf = new byte[1024]; private static int curChar; private static int numChars; p...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
69de05b33775a64655898598c71d8184
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { public static void main(String[]...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
b86c9f7da674b247fd1a6e5715060f5a
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.util.*; import java.io.*; public class BloodCousins { static ArrayList<Integer>[] graph; static int[][] bl; // static int[] sz; static int blSz; static int[] depth; static int[] ans; public static void main(String[] args) { FastScanner scanner = new FastScanner(); ...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
5ed1c02be6abbac77e9d5ddde941a0c4
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Ds { static int v; static int[][] par; static int[] dist; static int time = 0; static int[] start; static int[] end; stat...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
de01a957474bee8c457d65daa372d5f2
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.InputMismatchException; import java.util.Iterator; import java.util.TreeMap; public c...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
935dff06856aee05c207deed1dc39e49
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.StringTokenizer; public class Main { static final int log = 18; static ArrayList<Integer> adjList[], queries[]; static int[] L, P[], queriesValue, ans, size, biggest, cnt, tin, tout, vertex; static int time; public static void main(St...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
d7feb2f0422ae9a5a4f7bf61845fe1fb
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.io.IOException; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.InputStream; import java.lang.*; public class Source { public static void mai...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
d41535a13ea1479d9b17442008b00e4a
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
// practice with rainboy import java.io.*; import java.util.*; public class CF208E extends PrintWriter { CF208E() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF208E o = new CF208E(); o.main(); o.flush(); } int[] next, jj; int $ = 1; int link(int l, i...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
c112aef4131837abf50d36825f00ea1e
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.ArrayList; @SuppressWarnings("unchecked") public class E208 { int n; ArrayList<Integer>[] vs; ArrayList<Integer>[] depths; int[] first, las...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
cd8888c318e1b0b0af219f27fb2ace4f
train_003.jsonl
1343057400
Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let's call person a a 1-ancestor of person b, if a is the parent of b.Let's call person a a k-ancestor (k &gt; 1) of person b, if person b has...
256 megabytes
import java.util.*; import java.io.*; /* 6 0 1 1 0 4 4 1 2 1 24 0 1 1 1 2 3 3 3 4 5 6 6 7 7 8 9 9 12 14 15 0 21 22 23 1 12 2 */ public class BloodCousins { static int dfsid; static int[] start,end,depths; static ArrayList<ArrayList<Integer>> sibs; static ArrayList<Integer>[] children; public static void main(S...
Java
["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
2 seconds
["0 0 1 0 0 1 1"]
null
Java 8
standard input
[ "data structures", "binary search", "dfs and similar", "trees" ]
ce58d35343d66b962fb23b9963783acf
The first input line contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. The next line contains n space-separated integers r1, r2, ..., rn, where ri (1 ≤ ri ≤ n) is the number of person i's parent or 0, if person i has no parent. It is guaranteed that family relationships don't form cycles. Th...
2,100
Print m space-separated integers — the answers to Polycarpus' queries. Print the answers to the queries in the order, in which the queries occur in the input.
standard output
PASSED
78ac7c25bcd6d7706e917717d1e7d9ad
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.util.*; public class Main{ public static void main(String args[]){ Scanner s=new Scanner(System.in); int n=s.nextInt(); int k=s.nextInt(); String str=s.next(); int[] kk=new int[k]; for(int i=0;i<n;i++){ kk[str.charAt(i)-65]++; } Arrays.sort(kk); System.out.println(kk[0]*k); } }
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
404a1c42e7f18bac11a7f4d65290586c
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.util.Scanner; import java.lang.String; public class HelloWorld { public static void main(String[] args) { Scanner in = new Scanner(System.in); int input = in.nextInt(); int input2 = in.nextInt(); String a = in.next(); int[] m = new int[input2]; int min = input; for (int i...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
0616e70baa996697121934664b9c17e2
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package javaapplication2; import java.util.*; /** * * @author 1 */ public class JavaApplication2 { /** * @param args th...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
fc7f83217bafa05d0fb5bd55b8c8994f
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.util.Scanner; public class Class1 { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int k=input.nextInt(); String s=input.next(); input.close(); int[] rep=new int[k]; for(int i=0;i<n;i++) rep[(int)s.charAt(i)-65]++; int ans=rep[0]; ...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
4ce0a965039dd19d42ce1dccfc9c9b02
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int x = scan.nextInt(); int k = scan.nextInt(); String str = scan.next(); int min = x; int[] arr = new int[k]; for(int i=0;i<x;i++){ arr[str.charAt(i) - 'A']++...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
4defec95545d1fcdd27578a188bb58d0
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.*; import java.util.*; public class cf508A{ public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] s = br.readLine().split(" "); int n = Integer.parseInt(s[0]); int k = Integer.parseInt(s[1]); ...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
ef3338e4bad8e73318ac13f01699a1e6
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.ArrayList; import java.util.HashSet; public class A { public static void main(String...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
b96dfbd6a0bc44a150215cfefdf04dfc
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.io.BufferedReader; import java.util.*; public class hacker { /*FAtt gyi bbhai*/ static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedRea...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
2beb6e888cdfd8c3ee133139a0e90d2d
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class Prob { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String m = br.readLine(); String temp2[] = m.split(" "...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
6fd50ad6a083ca765e0ba5e38a3847d1
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author nirav */ public class Mai...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
f2c5e1a54c1df8dede60178c7aa547e2
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.IOException; import java.util.HashMap; import java.util.Scanner; public class Solutions { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); sc.nextLine(); String s = sc.nextLine(); HashMap<String,...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
764b6c5fce06ac648c498bfe92768081
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); int l = in.nextInt(); int k = in.nextInt(); String n = in.next(); int a[] = new int[26]; for (int i = 0; i < n.length(); i++) { a[n.charAt(i) - 'A']++; } int min...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
d6557388762c3265faa8a024da8607ba
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; public class _p001038A { static public void main(final String[] args) throws IOE...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
262412a8448a5fa223641371326a961a
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.io.DataInputStream; import java.io.FileInputStream; //Not Completed public class Sol1 { static final long MD = 1000000007; public static void main(String[] args)throws IOException { ...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
2a1e87cdfd4a62a63b9074335ad3c861
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.io.DataInputStream; import java.io.FileInputStream; //Not Completed public class Sol1 { static final long MD = 1000000007; public static void main(String[] args)throws IOException { ...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
1194c1a78a56bd763371174e547b733d
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.util.Scanner; public class equality { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); int k = scn.nextInt(); String s = scn.next(); int []cnt= new int[26]; for(int i=0;i<n;i++) { cnt[(int)(s.charAt(i)-'A')]++; } long min=Integer.MAX_V...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
5a9449823957dc846caf88702ecfd711
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Equality { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); int k = sc.nextInt(); String s =sc.next(); int[] zähler = new int[k]; for(int i= 0; i<k; i++) { zähler[i]=0; } ...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
cb61cdaaed4a86f736d1fbf8c11da638
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.util.*; import java.io.*; public class Equality { public static void main(String[] args) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String str=br.readLine(); String[] str1=str.split(" "); int n=Integer.parseInt(str1[0]); int k=Integer.parseInt(...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
f6855a961b9d7e153ec393991f20d3e3
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { try { BufferedReader br=new Buffer...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output
PASSED
a810a357f0f1a547cc61b14a65a00c56
train_003.jsonl
1536248100
You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining s...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in...
Java
["9 3\nACAABCCAB", "9 4\nABCABCABC"]
2 seconds
["6", "0"]
NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$0...
Java 8
standard input
[ "implementation", "strings" ]
d9d5db63b1e48214d02abe9977709384
The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.
800
Print the only integer — the length of the longest good subsequence of string $$$s$$$.
standard output