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
ba7e4cad8f930ef108b565502cbdbfa3
train_002.jsonl
1281970800
A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o...
256 megabytes
import java.util.*; public class Regular { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String s = scan.nextLine(); Stack<Character> list = new Stack<>(); int b = 0; for(int i = 0;i < s.length();i++) if(s.charAt(i) == '(') list.push(s.charAt(i)); else if(s.char...
Java
["(()))(", "((()())"]
5 seconds
["4", "6"]
null
Java 11
standard input
[ "greedy" ]
2ce2d0c4ac5e630bafad2127a1b589dd
Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106.
1,400
Output the maximum possible length of a regular bracket sequence.
standard output
PASSED
fbaacce71931a5f2d6ed9ea618941e4f
train_002.jsonl
1281970800
A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o...
256 megabytes
import java.util.Scanner; import java.io.BufferedReader; import java.io.*; import java.io.InputStream; public class Main{ public static void main(String[] args){ Scanner input = new Scanner(System.in); String str = input.nextLine(); int openningBraket=0,ans=0; for(int i=0;i<str.length();i++){ i...
Java
["(()))(", "((()())"]
5 seconds
["4", "6"]
null
Java 11
standard input
[ "greedy" ]
2ce2d0c4ac5e630bafad2127a1b589dd
Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106.
1,400
Output the maximum possible length of a regular bracket sequence.
standard output
PASSED
ce85502885e581bcce2a4c44da9e88a0
train_002.jsonl
1281970800
A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String [] args) { FastReader in=new FastReader(); String s=in.next(); int count=0; int total=0; for(int i=0;i<s.length();i++){ if(s.charAt(i) == '(') ...
Java
["(()))(", "((()())"]
5 seconds
["4", "6"]
null
Java 11
standard input
[ "greedy" ]
2ce2d0c4ac5e630bafad2127a1b589dd
Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106.
1,400
Output the maximum possible length of a regular bracket sequence.
standard output
PASSED
c66927d02a77db6fe4b12dc9da501bdb
train_002.jsonl
1281970800
A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o...
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 { public static void main (String[]args) throws IOException { Scanner in ...
Java
["(()))(", "((()())"]
5 seconds
["4", "6"]
null
Java 11
standard input
[ "greedy" ]
2ce2d0c4ac5e630bafad2127a1b589dd
Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106.
1,400
Output the maximum possible length of a regular bracket sequence.
standard output
PASSED
a8effa3570d951f38b8dfa18b0eb7b04
train_002.jsonl
1281970800
A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o...
256 megabytes
import java.io.*; import java.util.*; public class MyClass { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == n...
Java
["(()))(", "((()())"]
5 seconds
["4", "6"]
null
Java 11
standard input
[ "greedy" ]
2ce2d0c4ac5e630bafad2127a1b589dd
Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106.
1,400
Output the maximum possible length of a regular bracket sequence.
standard output
PASSED
6708867283476f7448d122e4750570b9
train_002.jsonl
1281970800
A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o...
256 megabytes
import java.util.*; public class Regular { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String s = scan.nextLine(); Stack<Character> list = new Stack<>(); int b = 0; for(int i = 0;i < s.length();i++) if(s.charAt(i) == '(') ...
Java
["(()))(", "((()())"]
5 seconds
["4", "6"]
null
Java 11
standard input
[ "greedy" ]
2ce2d0c4ac5e630bafad2127a1b589dd
Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106.
1,400
Output the maximum possible length of a regular bracket sequence.
standard output
PASSED
c9cf6ecbb77e75b564db71ef870e4177
train_002.jsonl
1281970800
A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o...
256 megabytes
import java.util.Scanner; public class test { public static void main(String[] args) { int cot = 0; int total = 0; Scanner in = new Scanner(System.in); String t = in.next(); for (int i = 0; i < t.length(); i++) { if (t.charAt(i) == '(') { cot++;...
Java
["(()))(", "((()())"]
5 seconds
["4", "6"]
null
Java 11
standard input
[ "greedy" ]
2ce2d0c4ac5e630bafad2127a1b589dd
Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106.
1,400
Output the maximum possible length of a regular bracket sequence.
standard output
PASSED
3336914947cf8ef53228c130f74345e8
train_002.jsonl
1301410800
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like th...
256 megabytes
import java.util.*; import java.io.*; public class TakeExp { public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); while(t-->0) { String a= ...
Java
["4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis"]
1 second
["word\nl10n\ni18n\np43s"]
null
Java 11
standard input
[ "strings" ]
6639d6c53951f8c1a8324fb24ef68f7a
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
800
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
standard output
PASSED
66f4da7458f4ac0d6ab2ca81f12c267f
train_002.jsonl
1301410800
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like th...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int a = input.nextInt(); a++; for (int i=0;i<a;i++) { String b = input.nextLine(); if (b.length() > 10) { int len = b.substring(1, b.length() - 1).length(); System.o...
Java
["4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis"]
1 second
["word\nl10n\ni18n\np43s"]
null
Java 11
standard input
[ "strings" ]
6639d6c53951f8c1a8324fb24ef68f7a
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
800
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
standard output
PASSED
707c5dab7e372b9d4ca7988c274e546d
train_002.jsonl
1301410800
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like th...
256 megabytes
import java.util.Scanner; public class WayTooLongWords { public static void main(String[] args) { Scanner k = new Scanner(System.in); int counter = k.nextInt(); String x = k.nextLine(); for (int i = 0; i < counter; i++) { x = k.nextLine(); int n = x.leng...
Java
["4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis"]
1 second
["word\nl10n\ni18n\np43s"]
null
Java 11
standard input
[ "strings" ]
6639d6c53951f8c1a8324fb24ef68f7a
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
800
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
standard output
PASSED
5e88f0ec75006651c529c80da40c1fd2
train_002.jsonl
1301410800
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like th...
256 megabytes
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 c=0; String str=sc.next(); int n=str.length(); if(n<=10) { ...
Java
["4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis"]
1 second
["word\nl10n\ni18n\np43s"]
null
Java 11
standard input
[ "strings" ]
6639d6c53951f8c1a8324fb24ef68f7a
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
800
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
standard output
PASSED
0b5ee689e103089d7b1219aeaa4389e9
train_002.jsonl
1301410800
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like th...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader input = new BufferedReader(new Inp...
Java
["4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis"]
1 second
["word\nl10n\ni18n\np43s"]
null
Java 11
standard input
[ "strings" ]
6639d6c53951f8c1a8324fb24ef68f7a
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
800
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
standard output
PASSED
6d41d6d09fb1b0949f53e9ae6468da12
train_002.jsonl
1301410800
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like th...
256 megabytes
import java.util.*; import java.lang.*; public class Strings{ public static void main(String args[]){ String str; Scanner sc = new Scanner(System.in); int test_cases = sc.nextInt(); for(int i=0;i<test_cases;i++){ str = sc.next(); int n = str.length(); if(n<=10...
Java
["4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis"]
1 second
["word\nl10n\ni18n\np43s"]
null
Java 11
standard input
[ "strings" ]
6639d6c53951f8c1a8324fb24ef68f7a
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
800
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
standard output
PASSED
0d3fa2bc83295614e6ff82f4263606ab
train_002.jsonl
1301410800
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like th...
256 megabytes
import java.util.*; public class Solution{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int words= sc.nextInt(); sc.nextLine(); String[] arr = new String[words]; for(int i=0;i<words;i++){ arr[i]=sc.nextLine(); } ...
Java
["4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis"]
1 second
["word\nl10n\ni18n\np43s"]
null
Java 11
standard input
[ "strings" ]
6639d6c53951f8c1a8324fb24ef68f7a
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
800
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
standard output
PASSED
be208f1a7a3a188ceb62579fb8cde922
train_002.jsonl
1301410800
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like th...
256 megabytes
import java.util.Scanner; // Java solution for codeforces problem 71A. "Way too long words" // the program takes input of a series of words // if the word is "too long" it outputs the first and last letter with // the number of missing characters in between them. // otherwise it outputs just the word itself public cla...
Java
["4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis"]
1 second
["word\nl10n\ni18n\np43s"]
null
Java 11
standard input
[ "strings" ]
6639d6c53951f8c1a8324fb24ef68f7a
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
800
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
standard output
PASSED
49e8f389b81d4c0c2341af6f36dcb972
train_002.jsonl
1301410800
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like th...
256 megabytes
import java.util.*; public class java{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); while(n-->0){ String s = sc.nextLine(); int len = s.length(); if(len>10){ Syste...
Java
["4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis"]
1 second
["word\nl10n\ni18n\np43s"]
null
Java 11
standard input
[ "strings" ]
6639d6c53951f8c1a8324fb24ef68f7a
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
800
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
standard output
PASSED
812f1f44d36fb3fe4f79fe68431efedd
train_002.jsonl
1301410800
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like th...
256 megabytes
import java.util.*; public class java{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); while(n-->0){ String s = sc.nextLine(); int l = s.length(); if(l>10){ ...
Java
["4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis"]
1 second
["word\nl10n\ni18n\np43s"]
null
Java 11
standard input
[ "strings" ]
6639d6c53951f8c1a8324fb24ef68f7a
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
800
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
standard output
PASSED
41509a4f9e570d156ce6d37cfa22f78a
train_002.jsonl
1301410800
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like th...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); for(int i=0;i<n;i++){ String word = scn.next(); int l = word.length(); if(l>10) { word = w...
Java
["4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis"]
1 second
["word\nl10n\ni18n\np43s"]
null
Java 11
standard input
[ "strings" ]
6639d6c53951f8c1a8324fb24ef68f7a
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
800
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
standard output
PASSED
008376249ae0cf9607d9846199a34423
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.util.ArrayList; import java.util.Arrays; public class WeirdSortProblem { public static void main(String[] args) throws IOException { Problem p = new Problem() ; } } class...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
7a48a3a84ab46a281fd9d0cf64e48e3c
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; /** * @author Nikita Gorokhov <wackloner@yandex-team.ru> */ public class B { private void solve() { int n = n...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
cbb6000eba78699cc566db02f5d9160d
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.math.*; import java.io.*; import java.util.*; public class Codeforces{ static int binarySearch(int arr[],int value,int start,int end) { int mid=(start+end)/2; int result; if(start<=end) { if(arr[mid]==value) { return value; ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
93f8c6b54dd6f7f079658eed224da600
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.util.*; public class A { static InputReader scn = new InputReader(System.in); static OutputWriter out = new OutputWriter(System.out); public static void main(String[] args) { int t = scn.nextInt(); while (t-- > 0) solve(); out.close(); } // 100 79 public static void s...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
d718aa7f3f863486b3c970bce726acb2
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class WeirdSort{ static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new Inp...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
1481855973c264471888d82419abdbe2
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.io.BufferedReader; import java.util.stream.IntStream; public class A { static class FastScanner { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringToken...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
67479b43834d5bba45181fcf5d2c3fea
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
/* package codechef; // don't place package name! */ import java.math.BigInteger; 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 void fun(boolean l,int n, int a[],int m,int p[]){ for(int i=1;i<=n...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
79715d0e8aeca0d1929896334e0bfbc1
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; public class B1311 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); sc.nextLine(); List<St...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
bad70882ffff74b5470584c313f3cee7
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.Scanner; import java.util.Set; /** * Built using CHelper plug-in * Actual solution is at the top * * @author ky112233 */ public class Main { public static...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
876a6486578417f611f59e9b856e672c
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; public class WierdSort { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); outer: while(t--!=0) { int n=sc.nextInt(),m=sc.nextInt(); int a[]=new int[n];int sor[]=new int[n]; int b[]=new int[100]; for(int i=0;i<n;i++) { a[i]=sc.next...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
8e9168ec012907ee4638bab5f1dad486
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class recc1311b { static BufferedReader __in; static PrintWriter __out; static StringTokenizer input; public static void main(String[] args) throws IOException { __in = new BufferedR...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
798024c0a020106c899cce410a271846
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; /* Hepler Class Methods **only Few Imp Ones** * int[][] getIntMatrix(String s,int r,int c) //Works only for int and long * char getCharacterValue(int i) * int getIntegerValueOfCharacter(char c) * boolean isPerfectSquare(int n) ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
e5ce8f3068495eca4203601379188c74
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { //static int p = 1000000007; static int p = 998244353; public static void main(String args[]) throws IOException { Scanner sc = new Scanner(); PrintWriter out = new PrintWriter(System.out); //Mod mod = new Mod(); //mod.preca...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
1d9ef181047808cd533c47c903d73c92
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; public class Try4 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++){ int n= sc.nextInt(); int m= sc.nextInt(); int[] a = new int[n+1]; ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
f4cdb4d970ccaca40eb68885a19387c5
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Cf182 implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCha...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
77376f0df47a268630bb50c413ce1141
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; public class Power { static long power(int a,int b){ if(b==0) return 1; long pow=power(a,b/2); if(b%2!=0){ return pow*pow*a; } else{ return pow*pow; } } static long gcd(long a,long b){ if(b==0) ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
404f29867f2ac0186d692c8f70a7abf6
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.StringTokenizer; import java.io.FileReader; import java.io.BufferedReader; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
83ec8f01a6c57f966ecb225a434a8bd5
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; public class WeirdSort { public static void main(String[] args) { Scanner s = new Scanner(System.in); int cases = s.nextInt(); for (int x = 0; x < cases; x++) { int n = s.nextInt(); int m = s.nextInt(); boolean yes = true; ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
c682989d2dcfd1c92bc05be2c1517d20
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; public class WeirdSort { public static void main(String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parse...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
9c12de2f48467da4198ef65f2e021261
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.util.*; public class GFG { public boolean check (int[] arr) { boolean issorted = true; for (int i = 1; i < arr.length; i++) { if (arr[i - 1] > arr[i]) { return false; } } return true; } public static void main...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
a56bfffad473e2aa8da80d9f3f3901b8
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.util.*; public class GFG { public boolean check (int[] arr) { boolean issorted = true; for (int i = 1; i < arr.length; i++) { if (arr[i - 1] > arr[i]) { return false; } } return true; } public static void main...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
678090677fff3b56bf2e08137834339a
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.*; import jav...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
104a743d37d09df1b0a8b2eb8e310913
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) { PrintWriter out=new PrintWriter(System.out); InputReader in=new InputReader(System.in); int t=in.nextInt(); while(t-->0) { int n=in.nextInt(); int m=in.nextInt(); int [] a=in.readArray(n); int [...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
07a9f94981a555a2bdeff3344c92b9cd
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); long x; int y=0; while (t-->0){ int n=sc.nextInt(); int m=sc.nextInt(); ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
ebed8b37213638008fd0c276ef990bf1
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; public class Main { // private int V; // private LinkedList<Integer> adj[]; // // Main(int v) { // V = v; // adj = new LinkedList[v]; // for (int i = 0; i < v; ++i) { // adj[i] = new LinkedList(); // } // } // // void addEdge(int v, int w) { // ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
4c4ea7e1df27286522f2a457d13f2aac
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Class2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int tt = Integ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
d57da5baafc331a75f844ca28f2d30dd
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.util.Scanner; public class Main { // static StreamTokenizer in; static Scanner sc; static PrintWriter out; int n; int[] a; int[] p; public static void main(String[] args) throws IOException { boolean oj = System.getProperty("ONLINE_JUDGE") != null; ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
424ddb2d2bbc6a131f2ad516d93b8851
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
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(); int m = sc.nextInt(); int[] arr = new int[n]; Set<Integer> se...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
563e58a53c569dffaebbde73251474eb
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.HashSet; import java.util.Scanner; public class Main { public static boolean get(int[] a, HashSet<Integer> set) { for (int i = 0; i < a.length - 1; i++) { for (int j = 0; j < a.length - 1; j++) { if (a[j] > a[j + 1]) { if (!set.contains(j)) ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
0bac60e93d42dd9bfa8ac72aa134c486
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
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 int n; static int org[]; public static void main (String[] args) throws java.lang.Exception { ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
d0ba5c9b36b208d0f9e6a211c08973f2
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.util.*; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Housni Abdellatif */ public class Main { public static void main(String[] args) throws IOException{ InputStream inputStream = System.in; OutputStream outputStream = System.out; ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
fb1ffd25315fc2e5122d60e7a127495a
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class A { static int find_par(int n){ if(par[n]==n) return n; return (par[n]=find_par(par[n])); } static void union(int a,int b){ int root1=find_par(a),root2=find_par(b); if(root1==root2) ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
1fad93dde201978bcde54a6edfbca915
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
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 CF1311B { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
b3b79dcfa78f06459290073c419d9be4
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.util.*; public class A { static InputReader scn = new InputReader(System.in); static OutputWriter out = new OutputWriter(System.out); public static void main(String[] args) { int t = scn.nextInt(); while (t-- > 0) solve(); out.close(); } // 100 79 public static void solve...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
55c7b8fca0bf82c2caf9eeeb732e6ee5
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Solution { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) throws IOException { ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
ff674325d609945eabc6c605ec4148c2
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; import java.io.*; public class Wierd_Sort { 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 S...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
58e9cc79f5c8bbb8c688f963355881ee
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.Arrays; import java.util.Scanner; import java.util.concurrent.ThreadLocalRandom; public class Main { static void swap(int a[] , int l , int r){ int temp = a[l]; a[l] = a[r]; a[r] = temp; } static void shuffle( int arr[] , int start , int end) { int n = arr.l...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
5a2fe0b7cf52c01a5c79ea95b8c3e8bb
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.Arrays; import java.util.Random; import java.util.Scanner; public class Main { static void swap(int a[] , int l , int r){ int temp = a[l]; a[l] = a[r]; a[r] = temp; } static void shuffle( int arr[] , int start , int end) { int n = arr.length; Random ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
2fa03ae6ca3a3045f34db1280d19a66b
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.util.*; import java.io.*; public class Main { static int mod=(int)1e9+7; public static void main(String[] args) throws Exception { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while (t-->0){ int n=sc.nextInt(),m=sc.nextInt(); int arr[]=new ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
bcbb866f05d34541ca00a5aa262164c5
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import javax.swing.*; import java.awt.desktop.SystemSleepEvent; import java.util.*; import java.io.*; public class Main { public static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedRead...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
b5cbf20355bcc748cd7b51649c515d22
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
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 sc = ne...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
9883e3bd0dbd9dc6b77236b42099b457
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.*; import java.util.*; public class test { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub Reader.init(System.in); int t=Reader.nextInt(); while(t-->0) { int n=Reader.nextInt(); int m=Reader.nextInt(); int arr[]=new int[n]; for(i...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
7cc455721c090e3a8751e046600f9b04
train_002.jsonl
1582554900
You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \dots, p_m$$$, where $$$1 \le p_i &lt; n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given posi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; public class Main { static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { br = new BufferedReader(new ...
Java
["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"]
2 seconds
["YES\nNO\nYES\nYES\nNO\nYES"]
null
Java 11
standard input
[ "sortings", "dfs and similar" ]
e1481b9d940407da75e11355b580f459
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m &lt; n \le 100$$$) — the number of elements in $$$a$$$ and the number of elements in $$$p$$$...
1,200
For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \le a_2 \le \dots \le a_n$$$) using only allowed swaps. Otherwise, print "NO".
standard output
PASSED
dbeac22a6e9f0546555069f4dfcc1e8a
train_002.jsonl
1549208100
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.Initially, there are $$$n$$$ superheroes in avengers team having powers $$$a_1, a_2, \ldots, a_n$$$, respectively. In one operat...
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.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Kraken7 */ public class Main { public static void main(String[] args)...
Java
["2 4 6\n4 7", "4 2 6\n1 3 2 3"]
1 second
["11.00000000000000000000", "5.00000000000000000000"]
NoteIn the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $$$2$$$ each.
Java 11
standard input
[ "implementation", "brute force", "math" ]
d6e44bd8ac03876cb03be0731f7dda3d
The first line contains three integers $$$n$$$, $$$k$$$ and $$$m$$$ ($$$1 \le n \le 10^{5}$$$, $$$1 \le k \le 10^{5}$$$, $$$1 \le m \le 10^{7}$$$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations. The second line contai...
1,700
Output a single number — the maximum final average power. Your answer is considered correct if its absolute or relative error does not exceed $$$10^{-6}$$$. Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is accepted if and only if $$$\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$$$.
standard output
PASSED
7539aeb569a55ad5bf95038caf0eb064
train_002.jsonl
1549208100
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.Initially, there are $$$n$$$ superheroes in avengers team having powers $$$a_1, a_2, \ldots, a_n$$$, respectively. In one operat...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class Solution{ public static void main(String[] args) { FastScanner fs = new FastScanner()...
Java
["2 4 6\n4 7", "4 2 6\n1 3 2 3"]
1 second
["11.00000000000000000000", "5.00000000000000000000"]
NoteIn the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $$$2$$$ each.
Java 11
standard input
[ "implementation", "brute force", "math" ]
d6e44bd8ac03876cb03be0731f7dda3d
The first line contains three integers $$$n$$$, $$$k$$$ and $$$m$$$ ($$$1 \le n \le 10^{5}$$$, $$$1 \le k \le 10^{5}$$$, $$$1 \le m \le 10^{7}$$$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations. The second line contai...
1,700
Output a single number — the maximum final average power. Your answer is considered correct if its absolute or relative error does not exceed $$$10^{-6}$$$. Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is accepted if and only if $$$\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$$$.
standard output
PASSED
6ef99ef05df1931c3efab7b089f3cb3a
train_002.jsonl
1549208100
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.Initially, there are $$$n$$$ superheroes in avengers team having powers $$$a_1, a_2, \ldots, a_n$$$, respectively. In one operat...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); U...
Java
["2 4 6\n4 7", "4 2 6\n1 3 2 3"]
1 second
["11.00000000000000000000", "5.00000000000000000000"]
NoteIn the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $$$2$$$ each.
Java 11
standard input
[ "implementation", "brute force", "math" ]
d6e44bd8ac03876cb03be0731f7dda3d
The first line contains three integers $$$n$$$, $$$k$$$ and $$$m$$$ ($$$1 \le n \le 10^{5}$$$, $$$1 \le k \le 10^{5}$$$, $$$1 \le m \le 10^{7}$$$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations. The second line contai...
1,700
Output a single number — the maximum final average power. Your answer is considered correct if its absolute or relative error does not exceed $$$10^{-6}$$$. Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is accepted if and only if $$$\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$$$.
standard output
PASSED
ac61c3291624334759c276d2e044af65
train_002.jsonl
1549208100
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.Initially, there are $$$n$$$ superheroes in avengers team having powers $$$a_1, a_2, \ldots, a_n$$$, respectively. In one operat...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int k=in.nextInt(); int m=in.nextInt(); double[] a=new double[n]; for (int i=0;i<n;++i) a[i]=in.nextDouble(); Arrays.sort(a); double res=0,sum=0,tot=0; for (int i...
Java
["2 4 6\n4 7", "4 2 6\n1 3 2 3"]
1 second
["11.00000000000000000000", "5.00000000000000000000"]
NoteIn the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $$$2$$$ each.
Java 11
standard input
[ "implementation", "brute force", "math" ]
d6e44bd8ac03876cb03be0731f7dda3d
The first line contains three integers $$$n$$$, $$$k$$$ and $$$m$$$ ($$$1 \le n \le 10^{5}$$$, $$$1 \le k \le 10^{5}$$$, $$$1 \le m \le 10^{7}$$$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations. The second line contai...
1,700
Output a single number — the maximum final average power. Your answer is considered correct if its absolute or relative error does not exceed $$$10^{-6}$$$. Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is accepted if and only if $$$\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$$$.
standard output
PASSED
9254d78798a8467e701fb0d58cd69bfd
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; pub...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
d8ca8ddb5517046fc6abf20634ccac74
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.io.BufferedInputStream; import java.util.Arrays; public class Solution { static BufferedInputStream in = new BufferedInputStream(System.in); public static void main(String[] args) throws Exception { int n = readInt(); Integer[] a = new Integer[n]; for (int i = 0; i < n; i++) a[i] = ...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
51f0f2c5b9b76c454af0b0316f94451d
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Throwable { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokeni...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
4c74a7468ef2c92b76e2da37080dc182
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Throwable { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokeni...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
b4f51587e90c367c8692b36da4ee6348
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
//package com.company; import java.io.*; import java.util.*; public class Main{ public static void main(String[] args)throws IOException { FastReader sc = new FastReader(); OutputStream output = System.out; PrintWriter out = new PrintWriter(output); //InputStream input = System.in;...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
b06e0f8a78ca6adfa8ccdaea51c051f4
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class C285 { public static void main(String args[])throws Exception { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); Long a[]=new Long[n]; for(int i=0;i<n;i++) a[i]=sc.nextLong(); Arrays...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
000af59c17865560c133c8fe194f8c5e
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { InputStream input = System.in; OutputStream output = System.out; InputReader in = new InputReader(input); PrintWriter out = new PrintWriter(output); Soluti...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
10406f8fb6c624e01c4a9711c9f93c9c
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * 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....
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
2fe72ce21acd412ec40f334ff7a1f756
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
ef82b714415415d3df01e66a5a48dc38
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
3440c51d8688430cada6b6f54b8509e2
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the te...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
d6be7e07ddddc3785dd860b4f4987512
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the te...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
327c6942e185c214404dab1472bf2daf
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
26c0d6f21fca508108478e92c3638195
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
e602b477537eaef6aeeaa59c8497bab3
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this temp...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
28d0c61f9cdf95c3aebf868a0d3092e0
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * 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....
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
ac8948650af37b0af30687958ae53eeb
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
5915f0e34f1ad39143aa8707601a005e
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
5f491769e795cf32083fe75619f1a656
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; //import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and op...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
b237bfb353736e5020b77185c340463a
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
29a41df85e8c31fa57b69b8ebb169644
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Tem...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
318856e9f1e6c4880e60df3b78749c08
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
4a57ef165a338393326971cbdfa8c203
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the te...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
256083097e920bd228456d374010b55e
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this temp...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
80ecf5738b7ce5e4e5a1caf1ef6ea8ea
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.Arrays; import java.util.Scanner; /* * 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 workzone */ public class permut_1 { public static void mai...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
68bc0f98752565377dfca11d7c66d82c
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * 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....
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
9ae46a012d27e29287f6f5940a2e0ef9
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
f3b77fc6f38272ccc2362d26faf70a14
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the te...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
4de80a5cf4966fa491d1fe7428c992ba
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.ArrayList; import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
46a047da68e4e8c4a2956af58543530f
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.Collections; //import java.util.LinkedList; //import java.util.List; import java.util.Scanner; import java.util.Vector; /* * 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....
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
294e5e75615e10904d95d62a1b2cc2cf
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.*; public class Main{ static Scanner in = new Scanner(System.in); public static void main(String args[]){ int x = in.nextInt(); Integer a[] = new Integer[x]; for(int i=0;i<x;i++)a[i] = in.nextInt(); Arrays.sort(a); long ans = 0; for(int i=0;i<x;...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
81c6b21278c2606112a8f3eb836402ce
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.util.*; public class Main{ static Scanner in = new Scanner(System.in); public static void main(String args[]){ int x = in.nextInt(); Integer a[] = new Integer[x]; for(int i=0;i<x;i++)a[i] = in.nextInt(); Arrays.sort(a); long ans = 0; int t = 1; ...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
b7bbe377cc21fd5f297584c774f720ed
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; import java.util.TreeSet; public class l025 { public static void main(String[] args) throws Exception { // StringTokenizer stok = new StringToke...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
b3d102de2e1127758d152899d7579baa
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class BuildingPermutation { static boolean[] b; static int max; static int min; public static void main(String[] args) throws IO...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
bae32bdd2d179ec665dbe3de4ac6fda1
train_002.jsonl
1363879800
Permutation p is an ordered set of integers p1,  p2,  ...,  pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1,  p2,  ...,  pn.You have a sequence of integers a1, a2, ..., an. I...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { Buffered...
Java
["2\n3 0", "3\n-1 -1 2"]
1 second
["2", "6"]
NoteIn the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).In the second sample you need 6 moves to build permutation (1, 3, 2).
Java 8
standard input
[ "implementation", "sortings", "greedy" ]
86d5da999415fa75b3ee754a2a28605c
The first line contains integer n (1 ≤ n ≤ 3·105) — the size of the sought permutation. The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).
1,200
Print a single number — the minimum number of moves. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output