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
4a648f9a1e12b8cb2d30d1cf3fb72b8a
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Problem503A { public static void main(String[] args) { // TODO Auto-generated method stub out=new PrintWriter (new BufferedOutputStream(...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
1983f014a7b7df332c190a8d51158362
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class towers { public static void main(String[] args) throws IOException{ InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String[] s = br.readLine().split...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
c1f0e246b7601ab0c387a8ef28b409c6
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.util.*; import java.io.*; public class C{ public static void main(String[] args) { MyScanner scan = new MyScanner(); PrintWriter pw = new PrintWriter(System.out); int n = scan.nextInt(); int h = scan.nextInt(); int a = scan.nextInt(); ...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
5ce82ae0154104480ac0792082891f84
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class CF1020A { public static void main(String args[]) throws java.lang.Exception { Scanner in = new Scanner (System.in); int n = in.nextInt(); int h = in.nextInt(); int min = in.nextInt(); int max = in.nextInt...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
c87fb5835b6806c3d4a6fcd186cab4a4
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
/** * Created by Jack on 11.08.2018. */ import java.util.Scanner; public class A { public static void main(String[] args) { int n , h , a , b , k; Scanner cin = new Scanner(System.in); n = cin.nextInt(); h = cin.nextInt(); a = cin.nextInt(); b = cin.nextInt(); ...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
c7131755b77de6695ac953024a79ebbf
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.util.*; public class building { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int h=sc.nextInt(); int a=sc.nextInt(); int b=sc.nextInt(); int q=sc.nextInt(); for(int i=0;i<q;i++){ int ans=0; int t1...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
33fdf1e963d345fec8009de501e90832
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.util.Arrays; import java.util.TreeMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; import java.util.Set; public class practice1 { public static void main (String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int h=sc.nex...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
1f118cbf91033e85c75fe59043ebce04
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class TestClass { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); String[] sa = s.split(" "); lo...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
234d49c2832138999a450c2c7b1b7f6d
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
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; /** * @author khokharnikunj8 */ public class Main { public static void main(String[] args) { ...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
fe9bc68dfb849cbc958ce8fcedf4dd6a
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Sol{ public static void main(String[] args) { FastScanner fi=new FastScanner(); int n,h,a,b,k; n=fi.nextInt(); h=fi.nextInt(); a=fi.nextInt(); b=fi.nextInt(); k=fi.nextInt(); while(k-- > 0){ int ta=fi.nextInt(); int fa=fi.nex...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
dde53aba89d36326a23dbda9c833956e
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.util.Scanner; public class ProblemA { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int h = scan.nextInt(); long a = scan.nextLong(); long b = scan.nextLong(); int k = scan.nextInt(); long ta, fa, tb, fb; long ans[] = new long[k]; ...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
17316bffdc1f509bd96ad245a0973d26
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class A_NewBuildingForSIS { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] inputLine = br.readLine().split(" "); int towers =...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
506c92b7d32dba00b0b5d3c34e09ca07
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
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.math.*; import java.util.*; import java.util.Map.Entry; public class Main { public static void main(String[] args) throws IOExce...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
c50e10b1bf5fc303fb8004010a271341
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.util.Scanner; public class A1020 { public static void main(String[] args) { Scanner s = new Scanner(System.in); long n = s.nextLong(); long h = s.nextLong(); long a = s.nextLong(); long b = s.nextLong(); long k = s.nextLong(); for (int i = 0; i < k; i++) { long x = s.nextLong(); lon...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
591880957abe85852499ba68dec739fa
train_002.jsonl
1533994500
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The buil...
256 megabytes
import java.util.Scanner; public class NewBuilding { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int h = in.nextInt(); int a = in.nextInt(); int b = in.nextInt(); int k = in.nextInt(); long[] result = ...
Java
["3 6 2 3 3\n1 2 1 3\n1 4 3 4\n1 2 2 3"]
1 second
["1\n4\n2"]
null
Java 8
standard input
[ "math" ]
bdce4761496c88a3de00aa863ba7308d
The first line of the input contains following integers: n: the number of towers in the building (1 ≤ n ≤ 108), h: the number of floors in each tower (1 ≤ h ≤ 108), a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h), k: total number of queries (1 ≤ k ≤ 104). ...
1,000
For each query print a single integer: the minimum walking time between the locations in minutes.
standard output
PASSED
d9bd6e4cebe0e16bc3e52c274f860fda
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Random; import java.util.StringTokenizer; public class Solution { public static void main(String[] args) { try (PrintWriter out = new Pri...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
854245ce03afd45df013af65072808ce
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.util.*; public class Mafia { static Scanner in = new Scanner(System.in); public static void main(String[] args) { int n = in.nextInt(); int ans = 0; double k = 0; for(int i = 0; i < n; i++) { int v = in.nextInt(); ans = Math.max(ans, v); k += v; } System.out.println((int)Mat...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
0231e9fab12194d433e94ecf930e55d1
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.util.*; public class Solution { public static void main(String []args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long sum = 0; long max = 0; for(int i = 0 ; i < n ; i++) { long term = sc.nextLong();...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
7f78daaa3e3b78dc89c9d3a22129bd23
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
2821ef8eb6b732046b5374a0484a4743
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.io.*; import java.util.*; public class Mafia { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new String...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
4c4d6872fe6be7e6589ffab978bfaae1
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class test { public static void main(String[] args) { // int t=fs.nextInt();while(t>0) // int test = fs.nextInt(); int test = 1; for (int cases = 0; cases < test; cases++) { int n=fs.nextInt(); long sum=0; long max=0; for(int i=0;i<n...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
1762877389e1f836cfc89022c6b1c2ab
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class d { public static void main(String[] args) throws IOException { // Scanner s = new Scanner(System.in); BufferedReader s = new BufferedReader(new InputStreamReader(System...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
0b8d612893192a16c1f60cee8b4c2e69
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.util.*; import java.io.*; public class hello { public static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
08be338e863697db0e93728e9972b9a1
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf348a { public static void main(String[] args) throws IOException { int n = ri(), a[] = ria(n); long l = maxof(a), r = 100000000000L, ans = r; while(l <= r) { ...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
0b014832a781b2f28cd12419fecfe8e4
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.io.*; import java.util.*; public class Test { public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); String[] ss=br.readLine().split(" "); int[] a=new int[...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
50987b697a07f5cc883fda038f6907b1
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main{ public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out)); public static void main(String sp[])throws IOException{ //Scanner sc = new Scanner(System.in); FastReader sc = new FastReader(); int n = sc.nextInt...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
280e73f61315ce8f32e214045a1db16f
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Mafia { public static void main(String[] args) { Reader1 s1=new Reader1(); int n=s1.nextInt(); long total=0; long max=0; for(int i=0;i<...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
efb17e7663693b9182cbbf54f9045b3f
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static void process(int test_number)throws IOException { long n = ni(), mx = 0l; long sum = 0l; for(int i = 1; i <= n; i++){ long x = nl(); mx = Math.max(mx, x); su...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
4ae3b73dec1a0df16c81fc97ee503cd7
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
//package random_practiceQuestions; import java.util.Scanner; public class A348 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int a=s.nextInt(); s.nextLine(); String[] l=s.nextLine().split(" "); lon...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
41a418b9bfe403632698a048dd0946c7
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] a = new long[n]; long sum = 0; long max = 0; for(int i = 0; i < n; i++) { a[i] = sc.nextLong(); sum += a[i]; max = Math.max(max, a[...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
261192daf2107e41d7b58a5b29e19e31
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.util.*; import java.io.*; public class File { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long total = 0; long max = 0; for (int i = 0; i < n; i++) { long num = sc.nextLong(); tota...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
ff2d239553bb1035317203bce21d6fb3
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.util.*; import java.io.*; public class File { public static void main(String[] args) { Scanner sc = new Scanner(System.in); /* There is some number of games that is our answer, x. We know that for each person, Ai, x - Ai games can have person Ai...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
77fb7597f4778b9a096d992e51d33caf
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class code { public static void main(String[] args)throws IOException { FastReader sc = new FastReader(); PrintWriter pw = new PrintWriter(System.out); int n = sc.ne...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
f9133a8fae9063505a46af1fd1798c4a
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.io.*; import java.util.*; public class Main { private static FastReader f = new FastReader(); public static void main(String[] args) { int n = f.nextInt(); long sum = 0; long max = 0; for(int i=0;i<n;i++) { long loc = f.nextInt(); max = Math...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
b52b4a70ed73c6a9ec27d6c5836e39bd
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
// #pragma GCC optimize("Ofast") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { static int infi = Integer.MAX_VALUE / 2, mod = (int) (1e9 + 7), maxn = (int) 1e5; static long infl = Long...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
da5e8e8368097c6b77f02a73fe6514fd
train_002.jsonl
1380295800
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number ...
256 megabytes
import java.util.*;import java.io.*;import java.math.*; public class Main { public static void process()throws IOException { long n=nl(); long sum=0l,mx=0l,inp=0l; for(int i=1;i<=n;i++){sum+=(inp=nl()); mx=Math.max(mx,inp);} long x=0l;//no. of supervision >= no. of games long l=...
Java
["3\n3 2 2", "4\n2 2 2 2"]
2 seconds
["4", "3"]
NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).
Java 11
standard input
[ "binary search", "sortings", "math" ]
09f5623c3717c9d360334500b198d8e0
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
1,600
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
a226eab12db348e70414bf6d99112ba1
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.util.*; public class main{ static int MAX = 100010; static long mod = 998244353; static ArrayList<Integer>[] amp, bmp; static boolean b[]; static Scanner sc = new Scanner(System.in); public static void main(String[] args){ int n = sc.nextInt(), k = sc.nextInt(); int arr[] = new int[n]...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
4a3729dcd6d55b0f76f225060f3fb1ce
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.util.*; import java.io.*; public class Main { static long mod = 1000000007; static long INF = 1000000000000L; public static void main(String[] args){ FastScanner scanner = new FastScanner(); int n = scanner.nextInt(); int k = scanner.nextInt(); int[] a = new int[n]; for(int i = 0; i < n; i++...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
18498429d7c28a0d706d330f8abbb233
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.math.BigInteger; import java.util.Scanner; import...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
d6b215cee5edcda4191b6427ad2a301e
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.*; public class Myclass{ static ArrayList[] a=new ArrayList[200001]; public void solve () { InputReader in = new InputReader(System.in); PrintWriter pw = new PrintWriter(System.out); int n=i...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
1fc718294add218769a844675e32e73c
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.util.*; import java.io.*; public class Solution { static ArrayList<Integer> graph[]; static int parent[]; static boolean vis[]; static int seive[]=new int[1000001]; static int dis[]=new int[1000001]; static int subtree[]=new int[1000001]; static int N =1000001; st...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
b3c4ecd61d4f1237a0b06bdf76c83a34
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.util.*; import java.lang.*; // StringBuilder uses java.lang public class mainClass { public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder st=new StringBuilder(); int n = sc.nextInt(); int k = sc.nextInt(); Array...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
fc7b884b16d553fc5b63b6af8dec6036
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
// Change Of Plans BABY.... Change Of Plans // import java.io.*; import java.util.*; import static java.lang.Math.*; public class equalizingbyDivision { static void MainSolution() { n = ni(); k = ni(); int ar[] = new int[n]; for (int i = 0; i < n; i++) ar[i] = ni(); ArrayLis...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
2b2afaaa439ff64cb6aa2d2d6e7d5c94
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
/* package whatever; // 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 Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader br...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
b140f2d5bc215cbe6d6c7f5552b71e5c
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.io.*; import java.util.Random; import java.math.BigInteger; import java.util.*; public class test { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; PrintWriter out = new PrintWriter(outputStream); InputReader...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
38ca7895263bfe24d98f12f75804bcca
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.util.*; import java.math.*; public class Main{ private static int max=200*1000+5; public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); int a[]=new int[n]; ...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
5f004ab70363ba16ff1ee426d804c5d3
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.StringTokenizer; @SuppressWarnings("unchecked") public class Problem_D { static final int INF = Integer.MAX_VALUE / 2; public...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
c88a147f32bfc49ab81b10ba0ef6d334
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Collections; import java.util.LinkedList; import java.util.StringTokenizer; public class Round582D2 { public static void main(String[] args) { // TODO Auto-generated me...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
37eac2eb6768eb959c0c3adfe3cc8357
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.management.MemoryType; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; import java.util.function.Function; public clas...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
e824bb5949b66c99bf0a3fe0e59dcecd
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static final long MOD = 998244353; public static void main(String[] args) throws IOException { FastScanner sc=new FastScanner(); int N = sc.nextInt(); int K = sc.nextInt(); int[] nums = new int[N]; ...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
24d92c4bfd798be1d57a1f5bdc2b120e
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Test2 { static int minOperations(int n, int k, int d, int[] a) { int MAX = 1000000; // Stores the number of moves // required to obtain respective // values from the ...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
f07082de0d755e811cfcc106811acc7b
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
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.util.Collections; import java.util.ArrayList; import java.io.InputStream; /** * @author khokharnikunj8 */ public class Ma...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
ebcfc2247812b54e4070606ab8b73341
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.io.*; import java.sql.Array; import java.util.*; import java.util.concurrent.ThreadLocalRandom; @SuppressWarnings("Duplicates") public class solveLOL { FastScanner in; PrintWriter out; boolean systemIO = true, multitests = false; int INF = Integer.MAX_VALUE / 2; void solve() { ...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
f09da1e3714bc469227dd42ad2927e64
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import static java.lang.Math.min; public class D2_1312 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedRea...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
59f1c933b22d195dd7622f21fcca2376
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
25bb1a44649ef7444840374b41997eff
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
// package cf1213; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Random; public class CFD2a { private static final String INPUT...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
c6b42af5f7b1734b856b95cd7ad01f44
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
// package cf1213; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; public class CFD2 { private static final String INPUT = "5 3\n" + "1 2 8 8 200000\n"; private static final in...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
b38687d01a9af18c47fe238e2b2a9906
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
// package cf1213; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Random; public class CFD2a { private static final String INPUT...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
d73b3bb8f36e354aaca2a9925e035b17
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class e { public static class FastReader { BufferedReader br; StringTokenizer st; //it reads the data about the specified point and divide the data about it...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
c96c137cbb581eb553a137e34a454398
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
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.security.KeyStore.Entry; import java.util.ArrayList; import java.util.Arrays; import java.util.PriorityQueue; import java.util.Strin...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
34c57ae21480ef44ad9813e5ae309e18
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.util.*; import java.io.*; public class HelloWorld { public void run() throws Exception { Scanner file = new Scanner(System.in); int times = file.nextInt(); int k = file.nextInt(); ArrayList<Integer> w= new ArrayList(); int max = Integer.MIN_VALUE; for (int i = 0; i < times; i++) {...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
11ec95996f47cc77b90f0e79357b425e
train_002.jsonl
1567175700
The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class HelloWorld { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.ne...
Java
["5 3\n1 2 2 4 5", "5 3\n1 2 3 4 5", "5 3\n1 2 3 3 3"]
2 seconds
["1", "2", "0"]
null
Java 8
standard input
[ "sortings", "brute force", "math" ]
ed1a2ae733121af6486568e528fe2d84
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the ...
1,600
Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.
standard output
PASSED
54e135d81ac139c419ff8fef29fc615d
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.util.Scanner; public class VikaAndSquares { public static void main(String[] args) { Scanner scan=new Scanner(System.in); long n=scan.nextLong(); int nex=(int) n; int[] a=new int[nex]; for(int i=0;i<nex;i++){ a[i]=scan.nextInt(); } lon...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
b40169eac7766828aa0f911f75ddd39b
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class main { static Scanner in = new Scanner(System.in); public static void main(String[] args) { long n = in.nextInt(); long[] ar = new long[(int)n]; for(int i = 0;i<n;i++){ ar[i]=in.nextLong(); } long min = ar[0]; long mini = 0; for(int i...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
26a4c975670ecf70d20dd45f006da6db
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class Main{ public static int[] xyz; public static void main (String[] args) throws java.lang.Exception{ //BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); InputReader in=new InputReader...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
ddfc2163137e2add83cc0d810a435719
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class Main{ public static int[] xyz; public static void main (String[] args) throws java.lang.Exception{ //BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); InputReader in=new InputReader...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
3a180262ff806c92f02fcc24611f77be
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.ArrayList; public class b { public static void main(String[] args) throws IOException { //BufferedReader input = new BufferedReader(new FileReader("i...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
2700db875fb31261305f838fa1674ca3
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.util.*; public class main{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n= scan.nextInt(); long least=Long.MAX_VALUE; int [] a = new int[n]; for(int i =0;i<n;i++) { a[i] = scan.nextInt(); if(...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
b65444c0cb00c62ed482bfeb3139a8d7
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] c = new int[n]; int min = Integer.MAX_VALUE; for (int i = 0; i < n; i++) { c[i] = s...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
b506d8112ee955c345c8dfaa63621415
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
//package CodeForces.Round337; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * Created by ilya on 27.12.15. */ public class B610 { public static void main(String[...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
5945422aad2b4dc3b8f7a5602c6f8ba4
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static void main(String args[]) { Scanner in; try { in = new Scanner(new File("input.txt")); } catch (Exception e) { in = new Scanner(System.in); } long n = in.nextInt(); long res = 0; long first = 0; long prev = 0; long...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
48c39e34c1b01f9213b418d605dc4009
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
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 * * @author safadurimo */ public class Main { public static void main(String[] args) { InputStrea...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
c7623ee9b06790813852464fbeaeef3f
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; import java.util.TreeSet; public class _337_1 { public static void main(String[] args) { // TODO Auto-generated method stub MyfScanner in=new ...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
6a0fbe61ca702b78a2b2a747bc02905d
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStream; /** * Built using CHel...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
0932fba57912350e6e787358b29213a7
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.io.*; import java.util.*; public class B { void solve() { int n = in.nextInt(); int[] colors = new int[n]; for (int i = 0; i < n; i++) { colors[i] = in.nextInt(); } List<Integer> indxs = new ArrayList<>(); int min = colors[0]; for (in...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
da4d5442c09cf8c95e654b3c2e272a1b
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; import java.util.ArrayList; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Likai */ public class Main { public static void main(String[] arg...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
f2790fe23a1c01a20dc528aa04d09c21
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class hef { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int a[] = new int[n]; long min = Long.MAX_VALUE; for(int i=0;i<a.length;i++) { a[i] = s.nextInt(); min = Math.min(...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
22aa0edb72a1e4c8ab3e1f1f74084acc
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.io.*; import java.util.*; /* * This file was created by ayush in attempt to solve the problem problems */ public class main { public void solve(int n,int[] litres, PrintWriter out) { int min = 2000000000; for(int i=0;i<n;i++){ min = Math.min(min,litres[i]); } int[] pos = new int[20000...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
768eda3a8ec36d2a7b9753ef1738d509
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
/* * Code Author: Jayesh Udhani * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar) * 2nd Year ICT BTECH Student */ import java.io.*; import java.util.*; public class Main { public static void main(String args[]) { InputReader in = new InputReader(System.in); Outpu...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
eaea837d8ea7d30a2092d946d590e3b9
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.io.*; import java.util.*; public class Main { private void solve() { int n = nextInt(); int min=1000000000; int a[] = new int[n]; int rast[] = new int[n]; int all[] = new int[n]; for (int i = 0; i < n; i++) { a[i]= nextInt(); if(mi...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
829a60c19dcdc4f42bfdf2a0388408a5
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class OneNumber { static FastReader in=new FastReader(); public static void main(String[] args) throws IOException { long n=in.nextInt(), sum=0,cho=Integer.MAX_VALUE,max=0; long an...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
f1bc56e4cc9335072edade5777fd9235
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.util.*; /** * Created by slie742 on 27/02/2016. */ public class VikaAndSquares { private static final Scanner INPUT = new Scanner(System.in); public static void main(String[] args) { int n = INPUT.nextInt(); int [] a = new int[n]; for (int i = 0; i < n; i++) { ...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
729cbac4845c50ff2871b252feea1366
train_002.jsonl
1451215200
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
256 megabytes
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); long[] arr=new long[n+1]; for (int i = 1; i < arr.length; i++) { arr[i]=sc.nextInt(); } long res=0,min=arr[1],count=0,maxcount=0,start=1,stop=1; for (int i = 2;...
Java
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
2 seconds
["12", "15", "11"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
Java 8
standard input
[ "constructive algorithms", "implementation" ]
e2db09803d87362c67763ef71e8b7f47
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
1,300
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
standard output
PASSED
6d836b88095fe8980f31e72eea8ec923
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.*; public class D218 { int INF = Integer.MAX_VALUE / 100; static Scanner sc = null; static BufferedReader br = null; static PrintStream out = null; static BufferedWriter bw = null; int ...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
7f1e0433e5b92c76804ec24eb875127b
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { static BufferedReader br; static StringTokenizer st; static PrintWriter out; public static Str...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
d9b97571fe743df91f8c571829442656
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.util.*; import java.io.*; public class TaskD { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int[] a = new int[n]; for (int i=0;i<n;i++) { ...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
a07f005ee4094b1de7900bdaef2223d3
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.io.IOException; import java.io.PrintWriter; import java.util.InputMismatchException; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author hitarthk */ publ...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
5f06a2ef7d417365d503e90852129c40
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Scanner; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * ...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
556bf7df4ba37355d68b47f50e99b3b2
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Map; import java.util.SortedMap; import java.util.StringTokenizer; import java.util.TreeMap; public class D { public static void main(String[] args) { MyScanner in = new MyScanner(); ...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
bd9037a925f55cbc21548df961422ee0
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.io.*; import java.util.*; public class r21824 { public void solve() { int n = in.nextInt(); long[] a = new long[n + 1]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); } a[n] = Long.MAX_VALUE; long[] cur = new long[n + 1]; ...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
522dd0ec33e714710ec65c1d8a57823f
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.TreeSet; /** * * @author nbheeroo */ public class Vessels { private void so...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
c5ce9e241ee86b31ff2002f0c8ef63a7
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; import java.util.TreeSet; /** * * @author nbheeroo */ public class Vessels { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); solve(in, out); out.clos...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
b910dd16ac1120d44a7532613af96a99
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.util.*; public class D { public static void main(String [] args){ final Scanner s = new Scanner(System.in); final int n = s.nextInt(); final int [] a = new int[n]; for (int i = 0; i < n; ++i){ a[i] = s.nextInt(); } final int [] amount = new int[n]; final SortedSet<Integer> notFull = new T...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
e6435a53e0e35207dcf4c4ec5a604019
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { /** * @param args */ static long ar[] = new long[200006]; static long rem[] = new long[200006]; static int next[] = new int[200006]; ...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
11daded65648b48a5c04438e1e8eb28e
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { /** * @param args */ static long ar[] = new long[200006]; static long rem[] = new long[200006]; static int next[] = new int[200006]; ...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
26739dc7e51bc84c582cdcf4867fa3b0
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import com.sun.org.apache.regexp.internal.recompile; import sun.print.resources.serviceui; import javax.management.remote.rmi._RMIConnection_Stub; import java.awt.*; import java.io.*; import java.util.*; public class D { private static int [] tree; public static void main(String [] args) throws IOException { Buf...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
884d1b4f79f5a59e18abb8ed29a456bf
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.io.*; import java.util.*; public class D { private static TreeSet<Integer> set; public static void main(String [] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out)); int ...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
d12f8d7773909b41d6240de8b7c6d2c6
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigDecimal; public class Task { public static void main(String[] args) throws Exception { new Task().solve(); } void solve() throws Exception { Reader in = new Reader("1.in"); PrintWriter out = new PrintWriter( new BufferedWriter( new OutputStreamWr...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
ab1b6d5de865ae310fd03a5ed8b6be5a
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import static java.util.Arrays.deepToString; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.StringTokenizer; import java.util.TreeSet; public class Main { static void solve() throws IOException...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output
PASSED
a8448760798afb10ce37c6a061137392
train_002.jsonl
1386493200
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially, all the vessels are empty. In some vessels water is poured. All the water that ...
256 megabytes
import static java.util.Arrays.deepToString; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.StringTokenizer; import java.util.TreeSet; public class Main { static void solve() throws IOException...
Java
["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3"]
2 seconds
["4\n5\n8", "7\n10\n5"]
null
Java 7
standard input
[ "data structures", "dsu", "implementation", "trees" ]
37e2bb1c7caeeae7f8a7c837a2b390c9
The first line contains integer n — the number of vessels (1 ≤ n ≤ 2·105). The second line contains n integers a1, a2, ..., an — the vessels' capacities (1 ≤ ai ≤ 109). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer m ...
1,800
For each query, print on a single line the number of liters of water in the corresponding vessel.
standard output