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 | 9541c0b0007716123258f8902880c63f | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.io.*;
import java.math.*;
import java.util.*;
public class Solution {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
void solve(Integer[] nums){
int sorted = 0;
for(int i=0; i<nums.length; i++){
if(nums[i] == i + 1) sorted++;
}
if(sorted == num... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 67ece6da14944f66affea9a6944aa731 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.util.Arrays;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t > 0) {
int n = sc.nextInt();
int[] a = new int[n];
for (... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | df34618f9088d688866ab299590a564b | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class B_Permutation_Sort {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
List<Integer> list = new ArrayList<Integer>();
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | a4c824c3f13dc917cb55c85c63f0a2aa | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.io.*;
import java.util.*;
public class Solution {
private static final int MOD_1 = 1000000000 + 7;
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() throws IOException {
br = new BufferedReader(new InputStreamReader(System.... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 841891237a7b2f893f8797544f44a3ae | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) {
FastScanner fs = new FastScanner();
int t = fs.nextInt();
for (int T = 0; T < t; T++) {
i... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 8777eaa7d6fc22efcd214be104b5e669 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
public class PermutationSort_1525B {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-->0){
int n = s.nextInt();
int [] a = new int [n];
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | c10006a3ca70e642faeb8ad9fa736301 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.util.Scanner;
public class Permutation_Sort {
public static boolean isSorted(int[] arr) {
for (int i = 0; i < arr.length - 1; i++) {
if (arr[i] > arr[i + 1]) {
return false;
}
}
return true;
}
public static void main... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 7f5cd4ec9af9dd7e53d355690f5f0ebb | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
public class Permutation_Sort {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int test=in.nextInt();
while(test>0){
int n,i,cn1=0,cn2=0,maximum=-1,minimum=100000,max1,max2;
n=in.nextInt();
i... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 1aee8c047371e23a95814dfa60f44b87 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class b1 {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int tc = scan.nextInt();
while((tc--) > 0){
int n = scan.nextInt();
int[] arr = new int[n];
for(int i=0;i<n;i++) arr[i] = scan.ne... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 682e0d37868934a6a4537795b60a9db9 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | /*==============================================
Name : Shadman Shariar ||
Email : shadman.shariar@northsouth.edu ||
University : North South University (NSU) ||
Facebook : shadman.shahriar.007 ||
==============================================*/
//import java.io.*;
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 822a9bef47c49a50d423fac4e9190c14 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.io.*;
import java.util.*;
public class B {
public static void main(String[] args){
FastReader sc=new FastReader();
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
int[] a=new int[n+1];
boolean sorted=true;
for(int i=1;i<=n;i++) {
a[i]=sc.nextInt();
if(a[i]... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | c9d8cdda1f68aff535298ce496729dc4 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException
{
FastScanner f = new FastScanner();
int ttt=1;
ttt=f.nextInt();
PrintWriter out=new PrintWriter(System.out);
for(int tt=0;tt<ttt;tt++) {
int n=f.nextInt();
int[] l=f.readA... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 172e094fd4731ce7d9c635eeff2c0385 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public final class coin34 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int testCases = scan.nextInt();
for (int i = 0; i < testCases; i++) {
int length = scan.nextInt();
int[] arr... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 96fc3f0b31b1fa00c21b01c5edc9c5e2 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Problem {
static int Mod = 1000000007;
public static void main(String[] args) {
MyScanner scan = new MyScanner();
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 57292dbe28c4bc214a348c6d5636e8c8 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 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 sout = new PrintWriter(outputStream)... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 69e1017678dcfcea6967a0055ba281ce | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class Sol53 {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int a[]=new int[n];
int count=0;
for(int i=0;i<n;... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 94939b3f334b0284125ceefb93b63190 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution
{
public static void main(String []args) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine());
for(int z=1;z<=t;z++)
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | e73db9f9238c5761fa84d36798db4842 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | /* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main"... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | af1a15f42aaeb2a1346a7ed1314a057d | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
public class Main
{
static long mod = (long) Math.pow(10, 9) + 7;
public static void main(String[] args)
{
FastReader sc = new FastReader();
int t = sc.nextInt();
while(t--!=0)
{
int n = sc.ne... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 9b5372c7d32efd71955cf93429763545 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
// * * * its fun to do the impossible * * * //
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class B {
static class Pair implements Comparable<Pair>{
int a;
int b;
Pair(int a , int b)... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | bee50331342938956f978bc47f4eeac4 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class MyClass
{
public static void main(String []args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 15e7fab9ac3e072177c829c805a60b71 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.lang.reflect.Array;
import java.util.Arrays;
public class PermutationSort {
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
publ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 2d3be4f6120a03d5e03bcbaecdd5bf82 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
public class B{
public static void main(String[] args)
{
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int t = fs.nextInt();
for(int tt=0;tt<t;tt++)
{
int n = fs.nextInt();
int[] arr = new int[n+1];
for(int i=1;i... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 19140a52aca2286374b95bc1cec30968 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedLi... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 318c01ddcb76f3d38bd59b04a23705df | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Checking {
static FastScanner fs;
static FastWriter fw;
static boolean checkOnlineJudge = System.getProperty("ONLINE_JUDGE") == null;
private static final int[][] kdir = new int[][]{{-1, 2}, {-2, 1}, {-2, -1}, {-1, -2}, {1, -2}, {2, -1}, {2,... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 50cc9a5b30fb80ef35a4be00582d18a0 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution{
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
public static void main(String[] YDSV) throws IOEx... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | e3895e323ada6064e6b0a2014179e0ff | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class test {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(Sys... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | d610a8fa899477488551eca4156fee7b | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import com.sun.security.jgss.GSSUtil;
import java.util.*;
import java.io.*;
public class cf1525B {
public static void main(String[] args) {
FastReader in = new FastReader();
int t = in.nextInt();
for (int i = 0; i < t; i++) {
int n = in.nextInt();
ArrayLi... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | d695f25bbc119fb17507cb427a120084 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.util.*;
import java.math.*;
import java.text.DecimalFormat;
//import java.io.*;
public class Experiment {
static Scanner in=new Scanner(System.in);
// static BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
public static void sort(int ar[],int l,int ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 3811600e27df7d6fa5591301dd06a4ac | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.Arrays;
import java.util.InputMismatchException;
/**
* Provide prove of correctness before implementation. Implementation can cost a lot of time.
* Anti test that prove that it's wrong.
* <p>
* Do not confuse i j k g indexes, upTo and length. Do extra methods!!! Write mor... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 486142864a1dda5cbc474c2f4f1d0477 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.Scanner;
public class specialPerm {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t-->0){
int n = scan.nextInt();
int[] arr = new int[n+1];
boolean found = false... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 6394c27efec9802c3ae87eab957f9763 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
public class A {
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br=new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while(st... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 0e970585fff47d26f8da18fde15a9ec7 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] srgs) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- >0){
int n=sc.nextInt();
int[] arr=new int[n];
for(int i=0;i<n;i++){
arr[i]=s... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | c5952b37954c847677564ae583d7179c | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes |
import java.util.*;
import java.lang.*;
import java.io.*;
public class B_Permutation_Sort
{
public static void main (String[] args) throws java.lang.Exception
{
FastReader sc =new FastReader();
int t=sc.nextInt();
while(t-->0)
{
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | bac47c90ffb0f3bc7feb7207035653f6 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | // created by faizal
import java.io.PrintWriter;
import java.util.*;
public class UziUzi {
static int[] dp;
public static void main(String[] args) {
long start = System.currentTimeMillis();
Scanner fk = new Scanner(System.in);
PrintWriter pr = new PrintWriter(System.out... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 138c40ea7b84c60643a941de18dad767 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int t=s.nextInt();
while(t-->0)
{
int n=s.nextInt();
int a[]=new int[n]; int b[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=s.nextInt(... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | d164e2c9aa106b610a7eca2a4acd3e34 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Practise
{
public static int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int t = in.nextInt();
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 5f413f67fc9cd30d3183161c7b57cea1 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | //1525B
import java.util.*;
public class PermutationSort {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-->0) {
int n = s.nextInt(); //upper bound 3
int[] a = new int[n];
for(int i = 0; i<n; i++) {
int x = s.nextInt();
a[i]=x... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 90feaddfb5902d3f6f6c5cc43b79a057 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | //1525B
import java.util.*;
public class PermutationSort {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-->0) {
int n = s.nextInt(); //upper bound 3
int[] a = new int[n];
int[] b = new int[n];
for(int i = 0; i<n; i++) {
int x ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 286b9e11b86fa4064fa8f3ebcc4a8e49 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | // Author : RegalBeast
import java.io.*;
import java.util.*;
public class Main implements Runnable {
static Input in = new Input();
static PrintWriter out = Output();
public static void main(String[] args) {
new Thread(null, new Main(), String.join(
"All that is gold doe... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | b936381b0afd15c1d139ce7ff0643723 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main{
static FastReader sc = new FastReader();
static void solve(){
int n = sc.nextInt();
boolean av = true;
int[] arr = new int[n];
arr[0] = sc.nextInt();
int max = arr[0] ,min = arr[0];
int M=0,m=0;
for(int i=1;i<n;i++){
arr[i] = sc.nextInt();
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | ed2d6983fb31353110b4ab59d83eaea6 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main{
static FastReader sc = new FastReader();
static void solve(){
int n = sc.nextInt();
boolean av = true;
int[] arr = new int[n];
arr[0] = sc.nextInt();
int max = arr[0] ,min = arr[0];
int M=0,m=0;
for(int i=1;i<n;i++){
arr[i] = sc.nextInt();
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 8ce4a3cf95a76d75e923666b74f0c51f | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | // MZML BOY//
import java.io.*;
import java.util.*;
public class Main{
static FastReader sc = new FastReader();
static void solve(){
int n = sc.nextInt();
boolean av = true;
int[] arr = new int[n];
arr[0] = sc.nextInt();
int max = arr[0] ,min = arr[0];
int M=0,m=0;
f... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 62892489d083a12b816a7ef8a3a372e7 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class test{
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
for(int i=0;i<t;i++){
int n = scn.nextInt();
int[] a = new int[n];
int[] b = new int[n];
f... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 5d8211c760ea722c8a00449ea56b9e19 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
public static void main(String[] args) {
FastReader in = new FastReader();
PrintWriter pw = new PrintWriter(System.out);
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 8895c56ab0f32839fd6bfdcd34fa09fb | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 974464b3a7afd3997b7fd0e5fb2e0881 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
import java.util.Scanner;
public class PermutationSort {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
int t = sc.nextInt();
boolean isSorted =false;
while(t--!=0) {
int n =sc.nextInt();
int[] a = new int[n];
for(int i=0 ;i<n;i++) {... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 9efb55d1001b34d8278369211a7576d2 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class rand2
{
public static void main(String[] args) throws IOException {
InputStreamReader r=new InputStreamReader(System.in);
BufferedReader br=new Buffer... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 4d59a3e14c8e6ae1c88b3c7ebe809e16 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 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.StringTokenizer;
import java.util.*;
public class PermutationSort {
static class FastScanner {
BufferedReader br;
StringTokenizer st;
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 796616c263e09101fec27fa87031f743 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class B109 {
public static boolean isIntegerArraySorted(int[] arr) {
for (int i = 0; i < arr.length - 1; i += 1) {... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | a9b0eebf586533a5a40d3afa6ffb4dda | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class PotionSort {
public static void main(String []args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t--!=0){
int n=sc.nextInt();
int ar[]=new int[n];
int a=1;
for(int i=0;i<n;i++){
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | a55ea8f71a1b45afc82607bc7d016e32 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class Main {
public static void main(String[] args) {
FastScanner in = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
while (t-- > 0)
solve(in,... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 174a0a5836278620ddc7c93f3a84a6b0 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
// Java Code for Palindrome Partitioning
// Problem
public class Code
{
// Driver code
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0)
{
int n=sc.nextInt();
in... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 55f0d078343c9c1d220d420434b6e24d | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 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 final class Solution {
static int gcd(int a, int b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
public static void main(Str... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 10bc8efc1b42d507f045a2aa0a7f3c0a | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class SortingSubArray {
public static void main(String[] args) {
FastReader sc = new FastReader();
int t = sc.nextInt();
while (t > 0) {
int n = ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 4fb2fa25252a871257229d704276ba91 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
import java.util.*;
public class Codeforce{
static FastReader fs = new FastReader();
public static void main(String[] args) {
int t = fs.nextInt();
while(t-- >0){
int n = fs.nextInt(), ans = 0;
int[] arr = fs.readArray... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | bac4272f700fa8449dc4af5acf13f957 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.function.BiConsumer;
import javax.sound.midi.SysexMessage;
import java.io.IOException;
import java.io.BufferedOutputS... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 8dfaa8450007fdd9cf721cbf7dbd6fde | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | // https://codeforces.com/contest/1525/problem/B
import java.util.Scanner;
public class p_15 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int test = sc.nextInt();
int ar[] = new int[test];
int an = 0;
for (int i = 0; i < ... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 6df892f421f2a806b6adcc07ca3a1db9 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.util.*;
public class Solution{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int[] arr= new int[n];
for(int i=0;i<n;i++){
arr[i]=sc.nextInt();
}
int f=1;
for(int i=1;i<n;i++){
... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 4cff971d99fc16922bc4a276a737fc32 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author dauom
*/
public class Main... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 2903f7b5ddbc155c275a45c4ba6a4425 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Stack;
impor... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 17 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 96e548147bc34453b54ba2a59baf3747 | train_110.jsonl | 1621152000 | You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it... | 256 megabytes | import java.io.*;
//import java.util.*;
public class PermutationSort {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
while(t-->0) {
int n = Inte... | Java | ["3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3"] | 2 seconds | ["1\n0\n2"] | NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is alre... | Java 17 | standard input | [
"constructive algorithms",
"greedy"
] | c212524cc1ad8e0332693e3cf644854b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to ... | 900 | For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order. | standard output | |
PASSED | 9da22c5b5b6ce74f9801b7b92bd74b0e | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.StringTokenizer;
public final class D {
static int[][] dp;
public static void mai... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | a9e7074d915e36e10574f4cee76685b5 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.StringTokenizer;
public final class D {
static int[][] dp;
public static void main(... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 289417c973f00e9a4e62eaa3ee054478 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.util.*;
public class D {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
ArrayList<Integer> occupied = new ArrayList<>();
ArrayList<Integer> vacant = new ArrayList<>();
for (int i = 0; i < n;... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 465f394c527189dda7a7039ef23f8891 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.util.*;
public class D {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
ArrayList<Integer> occupied = new ArrayList<>();
ArrayList<Integer> vacant = new ArrayList<>();
for (int i = 0; i < n;... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 0b7370c4d3431f7cc0221ad229d575d1 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.util.*;
public class D {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
ArrayList<Integer> occupied = new ArrayList<>();
ArrayList<Integer> vacant = new ArrayList<>();
for (int i = 0; i < n;... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | dae8c6010788d63efa5bcf527eaae6fb | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes |
import java.util.*;
public class D {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
occupied = new ArrayList<>();
vacant = new ArrayList<>();
for (int i = 0; i < n; i++) {
int x = scanner... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | db622f50b91d13e886fa57abf3cf54c2 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.util.*;
public class Solve{
static int[][] dp;
static ArrayList<Integer> o;
static ArrayList<Integer> z;
public static void main(String[] args){
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
dp=new int[n+1][n+1];
for(int i=0;i<=n;i++)A... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | c8b42bfdd62675c647f3b804f6d9b7a4 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;
public class Solve {
static int mod = 1000000000 + 7;
static int I... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | d74a5106699c21571f2eebc57e45c211 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes |
import java.io.*;
import java.util.*;
public class A {
static long modInverse(long a, long m) {
long m0 = m;
long y = 0, x = 1;
if (m == 1)
return 0;
while (a > 1) {
long q = a / m;
long t = m;
m = a % m;
a = t;
t = y;
y = x - q * y;
x = t;
}
... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 5e752ce281f015d7eae3a0c0b61c72fb | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
static class MyScanner {
BufferedReader br;
StringTokenizer st;
public MyScanner() {
br = new BufferedReader(new InputStreamReader... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 6f4406cac237ca2d0aaad67586592e66 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | /*
JAI MATA DI
*/
import java.util.*;
import javax.print.attribute.HashAttributeSet;
import java.io.*;
import java.math.BigInteger;
import java.sql.Array;
public class CP {
static class FR{
BufferedReader br;
StringTokenizer st;
public FR() {
br = new BufferedReader(new InputSt... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | dc6d237fc23bdc7f3b328cc4c9f3c095 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.io.*;
import java.util.*;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
// InputReader sc = new InputReader(System.in);
// PrintWriter out = new PrintWriter(System.out);
BufferedReader br = new BufferedR... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 88428d3da85c0f6b6176a7e5f86c9203 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | //package codeforces;
import java.io.PrintWriter;
import java.util.*;
public class codeforces {
static int dp[][]=new int[5001][5001];
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
int t=1;
for(int tt=0;tt<t;tt++)... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 1850b7595928e34cfa33d4af767588b7 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | //package codeforces;
import java.io.PrintWriter;
import java.util.*;
public class codeforces {
static int dp[][]=new int[5001][5001];
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
int t=1;
for(int tt=0;tt<t;tt++)... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 523829bd8f7cd123bbbf6880680d2878 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | //package codeforces;
import java.io.PrintWriter;
import java.util.*;
public class codeforces {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
int t=1;
for(int tt=0;tt<t;tt++) {
int n=s.nextInt();
... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 5fea88362a7b75179e470bf8e4cb3cf6 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | //package codeforces;
import java.io.PrintWriter;
import java.util.*;
public class codeforces {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
int t=1;
for(int tt=0;tt<t;tt++) {
int n=s.nextInt();
... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | a0c9dcf8516b62bbc2f4224377f52e5f | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.util.*;
import java.io.*;
public final class Solution{
static FastReader sc=new FastReader();
static PrintWriter writer=new PrintWriter(System.out);
static ArrayList<Integer>[] g;
static int[] vis, dis, parent;
public static int[][] dp;
public static int solve(ArrayList<Int... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 0d037ef355d442b8085faa65afe694ff | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.io.*;
import java.util.*;
public class Codeforces {
public static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader(String s) {
try {
br = new BufferedReader(new FileReader(s));
} catch (FileNotFound... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 3b91e32b71eac5ff732fb27246adf101 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes |
// 17-05 //
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class D {
static HashSet<Integer> set;
static int n;
static char s[];
static int dp[][];
static List<Integer> list = new Ar... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 5702c324862459a8da6c8ed5403bf57f | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes |
// * * * its fun to do the impossible * * * //
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class upD {
static class Pair implements Comparable<Pair>{
int a;
int b;
Pair(int a , in... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 80e09c8fe4f95c5949840cbd982f8a54 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | // ----------------------------------- Duniya Madarchod Hai -----------------------------------
import java.io.*;
import java.math.*;
import java.util.*;
public class Main
{
/*
public String wrd() throws IOException{return(read.next());}
public int ni() throws IOException{r... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | d9aac65d9ea90ff985ae156e6cb1f74d | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.rmi.dgc.Lease;
// Problem - Multiples of 3 onn codeforces MNedium difficulty level
// or check on youtube channel CodeNCode
public class Problem {
// static int Mod = 1000000007;
static int Mod=998244353;
static long dp[][];
... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 029ff1881f2f750c9b0f4aee25f83152 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Problem {
static int Mod = 1000000007;
public static void main(String[] args) {
MyScanner scan = new MyScanner();
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 1aa679880eb8922ef5ccd649370d344f | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Problem {
static int Mod = 1000000007;
public static void main(String[] args) {
MyScanner scan = new MyScanner();
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | db94a4548e74bf1b82bc00f0b0589af3 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
public class A{
// author: Tarun Verma
static FastScanner sc = new FastScanner();
static int inf = 100000... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 3dc3bbad785ffefefc3ee70722ae2a0b | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.util.*;
import java.io.*;
public class _1525_D {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int n = Integer.parseInt(in.readLine());
... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 3c57abba4af6215651afbc169aeb9635 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.util.*;
import java.io.*;
public class _1525_D {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int n = Integer.parseInt(in.readLine());
... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 767088435a010a850f52ec499bb0b6c3 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 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 final class Solution {
public static void main(String[] args) throws Exception {
Reader sc = new Reader();
BufferedWriter op = new Buf... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | e139d1c78501ea4e143bbcefb1272de8 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes |
/* 🅻🅴🅰🆁🅽🅸🅽🅶 */
//✅//
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.BigInteger;
public class D {
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Starts <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //
static FastReader sc = new FastReader();
static PrintWriter out = new PrintWrit... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | a40a7f82264b55adfbc58713c59f0334 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | de3670022a3811f26b3d384ec4ada255 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class d {
static BufferedReader br;
static long mod = 1000000000 + 7;
static HashSet<Integer> p = new HashSet<>();
static boolean debug =true;
// Arrays.sort(time , (a1,a2) -> (a1[0]-a2[... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 580d86da0f831ff2a28ced0bcf96d3d5 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | //package currentContest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
public class P4 {
static int dp[][]=new int[5000+1][5000+1];
public static void main(String[] ar... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 5953ae4c7ae347ded7aa642d690d9f62 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | //package currentContest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
public class P4 {
static int dp[][]=new int[5000+1][5000+1];
public static void main(String[] ar... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 72f2c4737cc48d71d756b2167f352125 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | //https://codeforces.com/contest/1525/problem/D
//D. Armchairs
import java.util.*;
import java.io.*;
public class CF_1525_D{
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(new OutputStrea... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | de3b8134eee551dfded490608ee1b105 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.util.*;
import java.io.*;
public class a2oj implements Runnable {
static FastReader sc;
static PrintWriter out;
static int mod = 1000000007;
public static void main(String[] args) {
new Thread(null, new a2oj(), "coderrohan14", 1 << 26).start();
}
@Override
... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 3773a56475c3ea58e6f68878177669d0 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class B {
static int mod=1000_000_007;
static int max=5001;
static List<Integer> rem=new ArrayList<>();
static List<Integer> ocu=new ArrayList<>();
... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | ee51da4d17c8c47a290e2245e9b3e141 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.io.*;
import java.util.*;
public class Solution {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
whil... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output | |
PASSED | 89d3cdb8fe96b7157c14aa389cd2a168 | train_110.jsonl | 1621152000 | There are $$$n$$$ armchairs, numbered from $$$1$$$ to $$$n$$$ from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than $$$\frac{n}{2}$$$.For some reason, you would like to tell people to move from their armchairs to... | 512 megabytes | import java.io.*;
import java.util.*;
import java.lang.Math;
public final class Solution {
static int retAns(ArrayList<Integer> zeroes, ArrayList<Integer> ones, int dp[][], int i, int j) {
if (i == ones.size()) {
return 0;
} else if (j == zeroes.size()) {
return -1;
} else if (dp[i]... | Java | ["7\n1 0 0 1 0 0 1", "6\n1 1 1 0 0 0", "5\n0 0 0 0 0"] | 2 seconds | ["3", "9", "0"] | NoteIn the first test, you can perform the following sequence: ask a person to move from armchair $$$1$$$ to armchair $$$2$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$7$$$ to armchair $$$6$$$, it takes $$$1$$$ minute; ask a person to move from armchair $$$4$$$ to armchair $$$5$$$, it takes $$$... | Java 11 | standard input | [
"dp",
"flows",
"graph matchings",
"greedy"
] | ff5abd7dfd6234ddaf0ee7d24e02c404 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 5000$$$) — the number of armchairs. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$). $$$a_i = 1$$$ means that the $$$i$$$-th armchair is initially occupied, $$$a_i = 0$$$ means that it is initially free. The number ... | 1,800 | Print one integer — the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.