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
0f013ec56c6d65449138df7a3e54ec35
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class ProblemC { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int t = Integer...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
2405ed4e00faf5453dc2537e4c087d29
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.io.*; public class Algorithm { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); BufferedWriter output = new BufferedWrit...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
b011eec0c62108f6227741a8d57d5825
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.io.*; public class Algorithm { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); BufferedWriter output = new BufferedWrit...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
20292218f92504ad161101970c4c37b6
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class C_Great_Graphs { private static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in))...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
9a2e422cf69363e14073736976554929
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; public class M{ private static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); private stat...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
f47507a11a149d799fd7fbd99faa9136
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; public class M{ private static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); private stat...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
b2c058340eab872b3c6d529570ada0f7
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.io.*; public class B{ public static void main(String[] args) { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t = fs.nextInt(); for(int tt=0;tt<t;tt++) { int n = fs.nextInt(); int[] arr = fs.readArray(n); arr = sort...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
11267baf4d5f67ad3e7708cec984bb9c
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedLi...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
01050444c26d18d8c5ea60f9bb59db14
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedLi...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e9ffc04c1adfd99644b5030aad6c5385
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import javax.swing.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main extends PrintWriter { static BufferedReader s = new BufferedReader(new InputStreamReader(Sys...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
450b27d3ee2d3e619906e228313459d1
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Sample { public static void main(String[] args) { ReadInput in = new ReadInput(); int T = in.nextInt(); while(T-->0) { int n = in.nextInt(); int[] are = in.readArray(n); Sor...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
f95d171e65bd48dd09380efbb73e83eb
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.io.*; public class three3 { static int n; static long[] arr; // static ArrayList<A>[] g; static long ans; public static void main(String[] args) throws IOException, FileNotFoundException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
c6d741c9196410424ec8c3a6b7b0c229
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.Arrays; public class GreatestGraphs { private static long solve(int n, int[] d, int[] a, long sum) { long s[] = new long[n]; long dp[] = new long[...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
66d8d7554bb5b8bd4e5bb40af7018b37
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.Arrays; public class GreatestGraphs { private static long solve(int n, int[] d, int[] a, long sum) { long s[] = new long[n]; long dp[] = new long[...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
9f303f5de75a6e3203e561fc379ef99b
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.Arrays; public class GreatestGraphs { private static long solve(int n, int[] d, int[] a, long sum) { long s[] = new long[n]; long dp[] = new long[n]; dp[0] = -sum; ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
45eca785fe832bbf69cf939bc58b1958
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
/* created by: nitin23329 on Date: 09/06/21 */ import java.io.*; import java.util.*; public class CodeForces { /*****************************************WRITING CODE STARTS HERE******************************************/ private static void solve(int test) { int n = sc.nextInt(); l...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
09a72f88ae1ea5af3803a93d357dc7dd
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
/* created by: nitin23329 on Date: 09/06/21 */ import java.io.*; import java.util.*; public class CodeForces { /*****************************************WRITING CODE STARTS HERE******************************************/ private static void solve(int test) { int n = sc.nextInt(); i...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
827eb0285625fe99d78ff8794e8fe7ca
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class Solution { /* -------------------------------------- Main Start ----------------------------------- */ public static void main(String[] args) throws IOException { FastReader fs = new FastReader(); int t = Integer.parseInt(fs.nextLine()); ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
08668dd7c5e408957f7f42f60236fddf
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
//package codechef; import java.util.Arrays; import java.util.HashMap; import java.util.Random; import java.util.Scanner; public class cfA { static int countSetBits(int n) { int cnt=0; while(n>0) { n=n&(n-1); cnt++; } return cnt; } private static void shuffleAr...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
60afc11fdb577e071de6260243a8ea9d
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { static int mod = 1000000007; //--------------------------------- Scanner -------------------------------...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
f5e99887ba9c8a22feead1f38c67f5ac
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.lang.*; import java.util.*; public class answer { static Scanner s=new Scanner(System.in); static long mod=1000000007; public static void main(String[] args) { int testcases=s.nextInt(); while(testcases-->0) { int n=s.nextInt(); long[] arr=new long...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
f9217963e210c9d6d896f0395cf23d85
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.lang.*; import java.util.*; public class answer { static Scanner s=new Scanner(System.in); static long mod=1000000007; public static void main(String[] args) { int testcases=s.nextInt(); while(testcases-->0) { int n=s.nextInt(); long[...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
f079d483298e689a8c0159b14dc51736
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Main { static long mod = (long) Math.pow(10, 9) + 7; public static void main(String[] args) throws IOException { FastReader sc = new FastReader(); StringBuilder fout = new StringBuilder(); int t = sc.n...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
6c2b08613138cdef8d819b4d83e0cf29
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class c{ public static void main(String args[]){ Scanner in = new Scanner(System.in); int t = in.nextInt(); for ( ; t > 0; t--){ int n = in.nextInt(); Integer[] vals = new Integer[n]; for (int i = 0; ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
32f941472d1443b4c9449773b2004f1a
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class ok { public static void main(String[] args) { FastReader sc = new FastReader(); int t = sc.nextInt(); while (t-- > 0) { int n ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
ba2744e62e8f6337ea78a61d61b2a423
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import java.text.*; public class Codeforces { static int mod=1000_000_007 ; public static void main(String[] args) throws Exception { PrintWri...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
630933cfec7945495d6113593d6a0300
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
9b1bce02f9e1fca71f2b58e7e1d67c8a
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
//package codeForces728; //package codeForces728; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class B { public static PrintWriter out =...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
f8ab8c4879942b0259e0da5fe42bdca3
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.io.*; public class C_1541 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); int[] array = sc.shuffle(sc.ne...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
d8d68818193fe5def9ffe7ea996ddd82
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.io.*; public class Main extends PrintWriter { Main() { super(System.out); } static boolean cases = true; // Solution void solve(int t) { int n = sc.nextInt(); int a[] = sc.readIntArray(n); if (n <= 2) { println(0); return; ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
caad3f2cf2f2cd3737ec97935b3da1c8
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.nio.charset.StandardCharsets; import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastRea...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
ff8bfa4519637bf4ca519aa47cacd000
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.PrintWriter; import java.util.*; public class Practice { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); long[] a = new long[n]; for (int ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
9bde7509a7c2d2c87f94cb13b867fc40
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(Syst...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e0dda4adecce25e9439d79c132494e81
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.io.*; public class C { static StringBuilder sb; static dsu dsu; static long fact[]; static int mod = (int) (1e9 + 7); static void solve() { long n = l(); long[] arr = readArray(n); arr = sortlong(arr); long ans = arr[arr.length - 1]; long[] neg = ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
62e3729da928a3732d85a571992d6e44
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.Arrays; import java.util.Scanner; /** * * @author Acer */ public class GreatGraphs_C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while(T-- > 0){ int n = sc.nextInt(); int...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
d9a1ace4096c52a2af665514e0ae3181
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Ar...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
178ff0203dab00f8942f99059014ae12
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class GreatGraphs { public static void main(String[] args) throws IOException { BufferedR...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
4a41f21e373e7283eebd866247592b6f
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class c { static BufferedWriter op = new BufferedWriter(new OutputStreamWriter(System.out)); public static void main(String args[]) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int q=Integer.parseIn...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
2f0f16bee5f6c1d7ed510e1289eea1bc
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main implements Runnable { int n, m, k; static boolean use_n_tests = true; long mod = 1_000_000_007; void s...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
c9017500ba3463741f4e55d6d3051fd3
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class Solution{ static FastScanner fs=new FastScanner(); static void output(){ int n = ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e9d9ea95851712923cea9806feb36070
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class CodeForce_GreatGraphs { public static void main(String[] args) { int t = ni(); StringBuilder outBuffer = new StringBuilder(); while (t-- > 0) { int n = ni(); List<Long> time = new ArrayList<>(); for (int i = 0; i < n; i++) { time.add(n...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
8aad099cd5d7dfdefcd8108415c8410d
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
// * * * the goal is to be worlds best * * * // import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class C { static class Pair implements Comparable<Pair>{ int a; int b; Pair(int a , int...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
8acd824f749a3b25eeb38ca9c0a194d2
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.sql.SQLSyntaxErrorException; import java.util.*; import java.io.*; import java.util.stream.StreamSupport; public class Solution { static long mod = (long)Math.pow(10,9)+7l; public static void main(String str[]) throws IOException { Reader sc = new Reader(); BufferedWriter output = ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
ec17c004bed1c7ec6bfe43097a476edc
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class C { // *** ++ // +=-==+ +++=- // +-:---==+ *+=----= // +-:---...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e75c591483fd3d165a50902b6df07747
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class greatgraph { private static class pair implements Comparable<pair> { int low, high; pair(int low, int high) { this.low = low; this.high = high; } @Override public int hashCode() { ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e8b121b1063648bad26d3d1beeb9924f
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
//import java.io.IOException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class GreatGraphs { static InputReader inputReader=new InputReader(System.in); ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
302a2c6e84a9037120b473e522c700ae
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; public class Solution { public static void main(String[] args) { ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
96e8c8c75a40b8764346212e241b42f4
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.io.*; public class GreatGraphs { PrintWriter out; StringTokenizer st; BufferedReader br; final int imax = Integer.MAX_VALUE, imin = Integer.MIN_VALUE; final int mod = 1000000007; void solve() throws Exception { int t = 1; t = ni(); ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
c821be86dd1fb2c9a904dcf841d6d024
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class C{ public static void main(String[] args){ FastReader sc = new FastReader(); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
cdd09de29fdc9ce42e25de7fe786827d
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; /* */ public class C { static FastReader sc=null; public static void main(String[] args) { sc=new FastReader(); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int d[]=sc.readArray(n); ruffleSort(d); n--; int a[]=new in...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e2487a9c09206b4d579f3421d505a4b9
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; /* */ public class C { static FastReader sc=null; public static void main(String[] args) { sc=new FastReader(); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int d[]=sc.readArray(n); ruffleSort(d); if(n==1) { System.out.p...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
d9deb1319468adb9b676bb65c30b94da
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class Main { static InputReader sc = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) throws IOException { ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
38a5f486e1f300d2dad5c89647ea5c29
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class C { static ArrayList<Integer> g[]; public static void main(String[] args)throws IOException { FastReader f=new FastReader(); StringBuffer sb = new StringBuffer(); int test=f.nextInt(); while(test-->0) { int n=f.nextInt(); ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
50bccdb8f25243713a7f8e86abd9b495
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
//https://codeforces.com/contest/1541/problem/C //C. Great Graphs import java.util.*; import java.io.*; public class CF_1541_C{ public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new OutputSt...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
42c9bf0b890bec7c44ac428882b44f36
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
// HOPE /////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
966e17cd0ee093f585c9b5de2d672a72
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String[] args) throws IOException { FastScanner fs = new FastScanner(); int t = fs.getInt(); while (t-- > 0) { int n = fs.getInt(); long[] ar = fs.getLongArray(n); ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
247268097230ef1632aa2001ee10fbe7
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class C { public static int[] sort(int arr[]) { List<Integer> list = new ArrayList<>(); for(int i:arr) list.add(i); Collections.sort(list); for(int i = 0;i<list.size();i++) { arr[i] = list.get(i); } return arr; } public static vo...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
f1d54b7a06fa6517b7c7757a5f8f68ea
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class GreatGraphs { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Inte...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e96dcc43a214b1f3531990fa1a32e770
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
// package com.prituladima; import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; import java.util.stream.IntStream; public class C { private void solve_() { int n = nextInt(); long[] d = nextArrL(n); if (n == 1 || n == 2) { println(0); ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
19111b8bc103624f7ed7111ce6a65b67
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new Input...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
fd85016e650b93dd536e463a348b51c8
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
/* author: rohit_03012002 */ import java.util.*; import java.io.*; import java.math.*; import java.io.FileWriter; import java.io.IOException; public class cf{ static class Pair{ int u; int v; Pair(int a,int b){ u=a; v=b; } ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
15aead9545f60843dfde7f7f74a90e57
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
//package round728.C; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); long sum1 = 0, sum2 = 0, sum3 = 0; long[] arr = new long[n]; PriorityQueue<Long> pq =...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
cdbf65bebd1c627a00ba7d3d4dc4428b
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.io.*; public class C{ private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); public static void main (String[] args) throws IOException { int...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
69e779a0ac8203b4f01b3f74927de323
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.*; public class copy { static long ans; public static long[] inv(long[] arr,int l,int r) { if(l>r) return null; if(l==r) { ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
9620f852e607a212b32f9ab3c4227976
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
/* TO LEARN 1-segment trees 2-euler tour 3-fenwick tree and interval tree */ /* TO SOLVE uva 1103 */ import java.util.*; import java.math.*; import java.io.*; import java.util.stream.Collectors; public class A{ static FastReader scan=new FastReader...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
c066e0d25d1b3417ce14f0862ade7ec6
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
// package com.company; import java.util.*; import java.io.*; import java.lang.*; public class Main{ public static void main(String args[]){ InputReader in=new InputReader(System.in); TASK solver = new TASK(); int t=1; t = in.nextInt(); for(int i=1;i<=t;i++) ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
ca28e3bfe28d5a6b2ba2096d5aae4e0e
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public final class C { public static void main(String[] args) { final FastScanner fs = new FastScanner(); ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e1a57fd16e9f3d9c46cb68ee4b78ffee
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.PrintWriter; import java.util.Arrays; import java.util.Random; import java.util.Scanner; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); for (i...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
88eaf9881ca273dd952fadd049844646
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
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.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.*; /** * Built using CHelper plug-in * Actual solution i...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e50343274f4a01397db49ec2a3e5c67f
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef {static class FastReader { BufferedReader br; StringTokenizer st; pub...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
2a73f77b74c95ca0b9db631dbd18038f
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.Arrays; public class C { static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); private static int nextInt() { ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
f04e55d657db131d73ca54b32565e4a5
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class GreatGraphs implements Runnable { void solve() { int t = ri(); while (t-- > 0) { int n = ri(); long[] arr = lArr(n); for (int i = 0; i < n; i++) { arr[i] = rl(); } shuffleSort(arr)...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
d827830513145df569e5ea4e3ed42872
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; import java.io.*; public class Main { public static void main(String args[])throws Exception{ Input sc=new Input(); StringBuilder sb=new StringBuilder(); int t=sc.r...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
109a52043bf989ca9cecca4d6006d365
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class GreatGraphs { public static void main(String[] args) throws Exception { BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder();...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
0df6e1984a6af72087a9a7a7694e6a39
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; public class CF1541C { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while((t--) > 0) { int n = scanner.nextInt(); int[] d = new int[n+1]; long[] sum ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
7492714bef4573d4af1d537e1fbcb05c
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class codeforcesC2{ 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\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
2515bb1da3a349b549bd23f9aca47da6
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
// package Codeforces728; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class C { public static void main(String[] args) { FastScann...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
f141610bb8cce8b49137f111371ec747
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; // import java.lang.*; import java.io.*; // THIS TEMPLATE MADE BY AKSH BANSAL. public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
bef41e4bd6ce9a6aff190dd392b1f25b
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t-->0){ int n = s.nextInt(); long arr[] = new long[n]; for(int i=0;i<n;i++)arr[i] = s.nextLong(); ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
25dbe8210bd2ec3313342f85a2eb4031
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class CF1541C { public static void main(String[] args) throws IOException { int t = ri(); while (t --> 0) { int n = ri(), d[] = ria(n); rsort(d); ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
97e187c7f4ef2d6a9f37526fac70b251
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
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.util.SplittableRandom; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.Input...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
85653df53ed5f0f56ffcc8ccca7e07ee
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class C{ public static void main(String[] args){ FS sc = new FS(); Prin...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
b4845a5e83077f0122dd8930edfe4161
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int tc = stdin.nextInt(); for(int t = 0; t < tc; t++) { int n = stdin.nextInt(); long[] a = new long[n]; for(int i = 0; i < n; i++) { a[i] = stdin.nextL...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
f16a4f8de6939bc8a98e978e0d219af4
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int tc = stdin.nextInt(); for(int t = 0; t < tc; t++) { int n = stdin.nextInt(); long[] a = new long[n]; for(int i = 0; i < n; i++) { a[i] = stdin.nextL...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
1cb70a7dad8f77cf14be330be8fbaab1
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Code { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0) { int n = sc.nextInt(); long[] arr = new long[n]; for(int i=0; i<n; i++) ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
48225118792dfebc163fa5b427c96b68
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Iterator; public class Main { private static final String NO = "No"; private static final String YES ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
b2f107f94129c2c2649533fb0430bc22
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; public class C_Great_Graphs implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
fb6aadb05f2c1b49c0efea73d8f8c034
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class GreatGraphOptimized { //Fast Input static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(Sys...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
c50459aafe34b45af250338dcd89de75
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Hello1 { public static void main(String[] args) throws IOException { FastReader s = new FastReader(); long t = s.nextInt(...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
31b63536765aedd12e8d3a9ecafd3a35
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author wilso */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
a040e1f04b83ff4893fb69d2547b30f7
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
/*input 3 3 0 2 3 2 0 1000000000 4 0 2 1 6 */ import java.util.*; import java.lang.*; import java.io.*; public class Main { static PrintWriter out; static int MOD = 1000000007; static FastReader scan; /*-------- I/O usaing short named function ---------*/ public static String ns(){return...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
ea83fc99e40873d6029d8fe91e665354
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class CodeForces { static reader input = new reader(); static PrintWriter output = new PrintWrit...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
23f271ee69d6e1bde9f2993cf77c6194
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main (String[] args) throws IOException { OutputWriter log = new OutputWriter(System.out); Reader sc=new Reader(); int t= sc.nextInt(); for(int time=0;time<t;time++) ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
0bd0a53179f3fbd4e6c12ed33d8157a3
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class q3 { public static class Edge { int v; int wt; Edge(int v, int wt) { this.v = v; this.wt = wt; } } public static void main(String[] args) throws Exception { BufferedReader b...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
6f2208815f839d31119975d15930e383
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.StringTokenizer; public class C implements Runnable { public static void main(String[] args) throws Exception {...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e424c88afd08961e2cb80f7568b1924c
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner s=new S...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e5c96baab6828e9b7e33fdaab4ea28e9
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.io.*; import java.util.*; public class prob3 { public static void main(String[] args)throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine().trim()); int t=Integer.parseInt...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
ca4717c67441037b8edd4aedaaaa84e8
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
import java.util.*; public class C{ static void sort(long[] A){ int n = A.length; Random rnd = new Random(); for(int i=0; i<n; ++i){ long tmp = A[i]; int randomPos = i + rnd.nextInt(n-i); A[i] = A[randomPos]; A[randomPos] = tmp; ...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
01519cfe3d98603e61fd6eae91f8a9d4
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
// package com.vikhyat; import java.io.*; import java.util.*; public class Main { //source: gfg static void merge(long arr[], int l, int m, int r) { // Find sizes of two subarrays to be merged int n1 = m - l + 1; int n2 = r - m; /* Create temp arrays...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output
PASSED
e3909d18a855a183d01956b2e2fe600f
train_107.jsonl
1624635300
Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that...
256 megabytes
// don't place package name class name "Codechef", Main only if class is public import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.InputStreamReader; import java.util.*; public final class Main{ public static class FastReader{ BufferedReader br; StringTok...
Java
["3\n3\n0 2 3\n2\n0 1000000000\n1\n0"]
2 seconds
["-3\n0\n0"]
NoteIn the first test case, you can add roads from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$, from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$, from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$, from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$, from pastu...
Java 11
standard input
[ "constructive algorithms", "graphs", "greedy", "shortest paths", "sortings" ]
7dfe0db5a99e6e4d71eb012fab07685b
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integer...
1,400
For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.
standard output