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
237b85c3987e0bddb9aef233b1695a5b
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.math.*; public class Task{ // ..............code begins here.............. static long mod=(long)1e9+7,inf=(long)1e17; static void solve() throws IOException { int n=int_v(read()); int[] a=int_arr(); List<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 8
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
3dd3178b4cb18046108dac01e78ddfd4
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.math.*; public class Task{ // ..............code begins here.............. static long mod=(long)1e9+7,inf=(long)1e17; static void solve() throws IOException { int n=int_v(read()); int[] a=int_arr(); TreeSet<...
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 8
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
31d57b31d0ef9207457fe78b0610b3b7
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.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.TreeSet; import java.io.InputStream; /** * Built using CHelper p...
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 8
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
2ea3a79c19a5a3b588b135195a78ee85
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.util.ResourceBundle.Control; import java.util.spi.TimeZoneNameProvider; import javax.management.openmbean.KeyAlreadyExistsException; // import java.lang.invoke.ConstantBootstraps; // import java.math.BigInteger; // import java.beans.IndexedPropertyChangeEvent; import java.io.*...
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 8
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
e1bd4f05eba1805f77770014543387a0
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.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); P...
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 8
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
b4a00ed4a7367917e82659f94e9b255f
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.util.*; public class ArmChairs { static int[]arr; static ArrayList<Integer>a; static ArrayList<Integer>b; static int dp[][]; public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); arr=new int[n]; for(int i=0;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 8
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
26684d1dee8eeb4f8e237167c06bf985
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.ArrayList; import java.util.Arrays; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; public class Armchairs { static List<Integer> zpos ; static List<Integer> opos ; static long[][] dp ; public static void main(String[] args) { // TODO Auto-generat...
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 8
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
61ca3378323cf03c3d1c062a7652f08f
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.ArrayList; import java.util.Arrays; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; public class Armchairs { static List<Integer> zpos ; static List<Integer> opos ; static long[][] dp ; public static void main(String[] args) { // TODO Auto-generat...
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 8
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
98f2025ebe18957290f4083847e74be6
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.ArrayList; import java.util.Arrays; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; public class Armchairs { static List<Integer> zpos ; static List<Integer> opos ; public static void main(String[] args) { // TODO Auto-generated method stub Scann...
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 8
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
6fe594f56f5d2c0dc33f81990d33624c
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 Main { static int i, j, k, n, m, t, y, x, sum = 0; static long mod = 1000000007; static FastScanner fs = new FastScanner(); static PrintW...
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 8
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
a0f02aaae1d0213a3a0277faeea10ffe
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://github.com/EgorKulikov/yaal/tree/master/lib/main/net/egork import java.util.*; import java.io.*; public class A{ static PrintWriter out; static InputReader in; public static void main(String args[]){ out = new PrintWriter(System.out); in = new InputReader(); new 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 8
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
89142fe7d5880942ffee10e8e7ce457d
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 P1525D { static int n; static int x; static int y; static ArrayList<Integer> xs = new ArrayList<>(); static ArrayList<Integer> ys = new ArrayList<>(); static int[][] dp; public static void main(String[] args) throws IOException { Scanner 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 8
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
9863df8808192141f8952b68b90ba38b
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 Main { public static void main(String args[]) { FastReader input=new FastReader(); PrintWriter out=new PrintWriter(System.out); int T=1; while(T-->0) { int n=input.nextInt(); int a[]=new...
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 8
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
63c2152c508399393809de9fe8493458
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 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 long dp[][]; public static void main(String[] args) throws java.lang.Exception { FastReader ...
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 8
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
5d1589b4e246d333099e635538ec7f81
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.ArrayList; import java.util.List; import java.util.StringTokenizer; public class D { public static void main(String[] args) { new D().solve(System.in, System.out); } public void solve(InputStream in, OutputStream out) { InputReader inputReader = new Input...
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 8
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
a52047f4ddfc31a6c04ad08808b5ea24
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.ArrayList; import java.util.List; import java.util.StringTokenizer; public class D { public static void main(String[] args) { new D().solve(System.in, System.out); } public void solve(InputStream in, OutputStream out) { InputReader inputReader = new Input...
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 8
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
3917553f153a932fac8f570025ec3e61
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
/* * akshaygupta26 */ import java.io.*; import java.util.*; public class D { static ArrayList<Integer> taken,vacant; static long dp[][]; public static void main(String[] args) { FastReader sc=new FastReader(); StringBuffer ans=new StringBuffer(); int test=1; while(test-->0) { ...
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 8
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
1612dcd6155d32f0621afa9f12027c05
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
/*========================================================================== * AUTHOR: RonWonWon * CREATED: 18.05.2021 02:33:46 /*==========================================================================*/ import java.io.*; import java.util.*; public class D { public static void main(Str...
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 8
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
4f072f674d05b549932c98c27dcae1de
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 final class Solution { static PrintWriter out = new PrintWriter(System.out); static FastReader in = new FastReader(); static long mod = (long) 1e9 + 7; static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(1, 0), new Pair(0, -1), new Pair(0, ...
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 8
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
153e8f61844cba111f0dda78126bd433
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 Try2{ public static void main(String[] args) throws IOException { FastScanner fs = new FastScanner(); // int t =fs.nextInt(); int t=1; while (t-- > 0) { int n = fs...
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 8
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
9bed219d45dd2f462b27ee9297938959
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.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.InputMismatchException; import java.util.List; import java.util.StringJoiner; public class Solution { private static List<Long> chairs; ...
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 8
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
c861e47a0408906776c572164198fddc
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 D1525 { static int[] arr; static int[][] dp; public static int dp(int idx, int av) { if (idx == arr.length) { if (av == 0) { return 0; } return (int) 1e9; } if (dp[idx][av + arr.length] != -1) { return dp[idx][av + arr.length];...
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 8
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
4b98dce3c12130287769f06c55644438
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 C { static ArrayList<Integer>one; static ArrayList<Integer>zero; static int dp[][]=new int[5001][5001]; public static void main(String[] args) { Scanner sc=new Scanner(System.in); one =new ArrayList<>(); zero=new ArrayList<>(); int n =sc.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 8
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
5df4a52e0d98ebf9a0b55cbb1691ceeb
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 Main{ static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new String...
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 8
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
2b4c93e825d8d5df4b53eff666e2b9c4
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 C { //lexographically best moves... public static int dx[] = { 1, 0, 0, -1 }; public static int dy[] = { 0, -1, 1, 0 }; public static ArrayList<Integer> occ=new ArrayList<>(); public static ArrayList<Integer> unocc=new ArrayList<>(); public static long ...
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 8
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
42ef2a1803fce76c26005e16fcf7f3a6
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 Armchairs { public static PrintWriter out; static int mod=998244353; public static void main(String[] args)throws IOException { JS sc=new JS(); out = new PrintWriter(System.out); int t=1;//sc.nextInt(); while(t-->0) { int n=sc.nextIn...
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 8
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
a05ba822fa8813efaf4145da27cd5b55
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 Armchairs{ public static void main(String[] args) { FastReader fr = new FastReader(); PrintWriter out = new PrintWriter(System.out); Scanner sc= new Scanner (System.in); //Code From Here---- int t =fr.nextIn...
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 8
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
1a690bcb99bc65ec19f22d3ff13af901
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.StringTokenizer; public class NewSolution { private static final int MAX = Integer.MAX_VALUE; public static void main(String[] args) { ...
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 8
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
4f04112f98abffe6664668e4150ed982
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.io.BufferedReader; import java.io.IOException; import java.util.Collections; import java.io.InputStreamReader; import static java.lang.Math.*; import static java.lang.System.*; public class Main1 { static ArrayList<Integer> list1 = 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 8
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
303797f9c8799cb406bf3131dca6f29f
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 Armchairs { public static int findMinTime(List<Integer> zeros, List<Integer> ones) { if (ones.size() == 0) return 0; int oneSize = ones.size(); int zeroSize = zeros.size(); int [][] time = new int [oneSize + 1][zeroSize + 1]; for (int i=1; i<=oneSize; 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 8
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
ccf65738913c742a4950efcf32fa644e
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.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.StringTokenizer; public class ProblemD { public static void main(String[] args) throws IOE...
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 8
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
8d7c1385a45d8a451a4d7ddd781ef141
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.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; PrintWriter out = new PrintWriter(outputStream); InputReader in = new Input...
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 8
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
10c221c99b89fd715ce857335603716d
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.*; public class Solution { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer st = new StringTokenizer(""); String next() { if (!st.hasMoreToke...
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 8
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
094a504e744a2940cc0f68479d524934
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 Armchairs { static int n; static int[] arr; static int[] pos; static int[][] dp; public static void main(String[] args) { Scanner scan = new Scanner(System.in); n = scan.nextInt(); arr = new int[n]; pos = new int[n]; Arrays.fill(pos, -1); 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 8
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
b436a162238cea484c7dcb72e3635526
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.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] a = new int[n]; for(int i=0; i<n; i++) { a[i] = in.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 8
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
406859f989127c46aba4fefa9b81ae0b
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.util.Arrays; public class codeforces { static int[]av; static int[]oc; static int[][]memo; static int n; public static void main(String[] args) throws Exception { // int t=sc.nextInt(); // while(t-->0) { n=sc.nextInt(); int[]a=new int[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 8
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
f2657104901500e89b9e1f1c045e51a8
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 class Main { static PrintWriter pw; static Scanner sc; static StringBuilder ans; static long mod = 1000000000+7; static void pn(final Object arg) { pw.pri...
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 8
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
b24fd033f4ae2d2fbf721737bda4213b
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.Scanner; import java.util.ArrayList; public class D_Armchairs{ public static long solve(ArrayList<Integer> zeroes,ArrayList<Integer> ones,int i, int j,long matrix[][],int count){ if(matrix[i][j]!=0){ return matrix[i][j]; } ...
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 8
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
2e6d5e0e9ec3bfe6820fbd690a0a839c
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
/* In_The_Name_Of_Allah_The_Merciful */ import java.util.*; import java.io.*; public class Main { PrintWriter out; FastReader sc; long[] m1= {(long)(1e9+7),998244353}; long mod=m1[0]; long maxlong=Long.MAX_VALUE; long minlong=Long.MI...
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 8
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
b2a2812b41cd343c284f36d9de836c92
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.lang.*; import java.util.*; import java.io.*; public class Main { static void deal(int[] arr,int n) { int m1 = 0; int m2 = 0; for(int i=0;i<n;i++) { if(arr[i]==1) { m1 ++; } else { m2 ++; } ...
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 8
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
60d236de97cb1f3d0b0b49064eaebc54
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 Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); StringBuffer out=new StringBuffer(); int t=1; while(t--!=0) { int n=in.nextInt(); ArrayList<Integer> list[]=new ArrayList[2]; for(int i=0; i<2; i++) list[i]=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 8
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
dfcfc664d181c27a9b7effef8d112cd1
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 testing; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class A { static public class Pair{ int a,b; public Pair(int a,int b) { this.a = a; this.b = b; } } static class cmp impl...
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 8
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
5abb97eed2245f12e90dcf29160319ef
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.*; import java.lang.*; public class Practice { public static long mod = (long) Math.pow(10, 9) + 7; public static long tt = 0; public static void main(String[] args...
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 8
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
e7ed7e50892bffc3bb8fdc73de3f148d
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 sc=new Scanner(System.in); ArrayList<Integer> o=new ArrayList<Integer>(), e=new ArrayList<Integer>(); int n = sc.nextInt(),dp[][]=new int[n+1][n+1]; for(int i=1;i<=n;i++){ int x=sc.nextInt(); if(x==1)o.add(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 8
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
604a51b8acf6c6bec39b600300be3166
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
/* bts songs to dance to: I need U Run ON Filter I'm fine */ import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.out; import java.util.*; import java.io.*; import java.math.*; public class x1525D { static long INF =...
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 8
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
da8d18b06ccbbf988e20b38f84ee3962
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
/* bts songs to dance to: I need U Run ON Filter I'm fine */ import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.out; import java.util.*; import java.io.*; import java.math.*; public class x1525D { static int INF = ...
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 8
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
e29292e7a0b23a5114b4c37640d3498c
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.math.BigInteger; import java.util.*; public class tr1 { static PrintWriter out; static StringBuilder sb; static long mod = (long) 998244353; static int[][] memo, mat; static int n, m; static ArrayList<Integer>[] ad; static HashMap<Integer, Integer>[] going; static long...
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 8
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
cf1c8f900820412b82ad060d373e0d84
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.math.*; import java.math.BigInteger; //import javafx.util.*; public final class B { static StringBuilder ans=new StringBuilder(); static FastReader in=new FastReader(); static ArrayList<ArrayList<Integer>> g; static long mod=(long)(1e9+7); static 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 8
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
709c75fa4607df0824e6fa713029d9f6
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.util.Arrays; import java.io.IOException; import java.util.ArrayList; import java.io.UncheckedIOException; import java.util.List; import java.io.Closeable; import java.io.Writer; import java.io.O...
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 8
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
63751ce2d1ea67aa45f4ef938faa4c79
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.IOException; import java.io.InputStream; import java.io.PrintStream; import java.io.PrintWriter; import java.util.*; import static java.util.Arrays.sort; publi...
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 8
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
2c96449106a2938bf9bc925cdad685e2
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 Solution { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din ...
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 8
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
6623b8fb573df19789d48579c02e637e
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.util.concurrent.TimeUnit; import java.io.*; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; public class D_Armchairs{ public static void solve(){ } static Printer p=new Printer(); public static void main(String ...
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 8
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
834a68aa79c9507c95aaba898de6364f
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.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Armchairs { public static PrintWriter out; public static void main(String[] args) { MySc...
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 8
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
1bd7cd1d074d10e537c4ed44792fb28c
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.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; import java.util.concurrent.ThreadLocalRandom; public class c731 { pu...
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 8
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
d652cfaa37e6fd25481b6fdaa683360d
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.Collections; import java.util.StringTokenizer; public class App { public String getGreeting() { return "Hello World!"; } static 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 8
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
f37fd11e3f62037a312d3d32558a553c
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.*; // Solution public class new1{ public static int func(ArrayList<Integer> full, ArrayList<Integer> empty, int x, int y, int[][] dp) { int n = full.size(); int m = empty.size(); if(x == n) return 0; if(dp[x][y] != -1) return dp[x][y]; int a = 0; int b = Integer....
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 8
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
30e351e6eec411b7a35095464c45d25e
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.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Random; ...
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 8
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
f1fa79dc3da5147fca0806991dc16271
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.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Random; ...
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 8
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
5ad604a072cb25e808b76a2d2321b041
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 Main { public static void main(String[] args) throws IOException { //BufferedReader f = new BufferedReader(new FileReader("uva.in")); BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new Prin...
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 8
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
ea837b12b3adf8eec677b2d88b07157a
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.Scanner; import java.util.ArrayList; import java.lang.Math; public class fell { private static final Scanner cin = new Scanner(System.in); private static final int maxVal = 1000000000; public static void main(String[] args) { int n = cin.nextInt(); ArrayList<Integer> a = new ArrayLis...
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 8
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
70691c1ed2eb240507992bb5f2c7bfe6
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 FinalGrind; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class Problem9 { public static void main(String[] args)throws IOException { BufferedReader br=new BufferedReade...
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 8
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
14802a890b1f82eac09538e4a42ed834
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 Main { static PrintWriter pw; static Scanner sc; static long ceildiv(long x, long y) { return (x+y-1)/y; } static int mod(long x, int m) { return (int)((x%m+m)%m); } static void put(TreeMap<Integer, Integer> map, Integer p){if(map.containsK...
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 8
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
3065e1ab5551a61f06ce6b53bfa42165
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 Longjumps { public static void main(String[] args){ Scanner sc=new Scanner(System.in); ArrayList<Integer> o=new ArrayList<Integer>(), e=new ArrayList<Integer>(); int n = sc.nextInt(); for(int i=1;i<=n;i++){ int x=sc.nextInt(); if(x==1)o.add(i); else ...
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 8
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
f2fd6cebd16dc1a0a99358c973f4fc5c
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
// Don't place your source in a package import javax.swing.*; import java.lang.reflect.Array; import java.text.DecimalFormat; import java.util.*; import java.lang.*; import java.io.*; import java.math.*; import java.util.stream.Stream; // Please name your class Main public class Main { static FastSca...
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 8
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
7777b6b4db012852e8d186f5a8a5cfdb
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 long res; public static void main(String[] args) throws Exception { FastReader fr=new FastReader(); int n=fr.nextInt(); ArrayList<Integer> oc=new ArrayList<>(); ArrayList<Integer> em=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 8
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
b2b64f13b7c9874b1b75f85c1e37c2ca
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.math.BigInteger; //import static java.lang.Math.max; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java....
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 8
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
9828f1e328fe35b2b24cfba6a8354c13
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.math.*; public class CF1525D { static final Random random=new Random(); static boolean memory = true; static void ruffleSort(int[] a) { int n = a.length; for (int i=0; i<n; i++) { int oi=random.nextInt(n), temp=a[oi];...
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 8
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
9a299d5d4265afbaf0922710d447f56e
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 CodeForces1525C{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); ArrayList<Integer> o=new ArrayList<Integer>(), e=new ArrayList<Integer>(); int n = sc.nextInt(),dp[][]=new int[n+1][n+1]; for(int i=1;i<=n;i++){ int x=sc.nextInt(); if(x...
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 8
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
c594e7ef93ff166a26b8fed9b46e54f7
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.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=sc.nextInt(); ArrayList<Integer> pos=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 8
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
537a0f859241b0f8cd72a2cba7fa80c0
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.Arrays; import java.util.Scanner; public class A { static Scanner scan = new Scanner(System.in); public static void slove(){ int n = scan.nextInt(); int[] a = new int[n+10]; int[] b = new int[n+10]; int[] c = new int[n+10]; int c1 = 1,c2 = ...
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 8
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
aac9a0c989bbfdfdb6a756fc9e4c6a22
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.math.*; /** * * @Har_Har_Mahadev */ /** * Main , Solution , Remove Public */ public class A { private static long[][] dp; private static ArrayList<Integer> lis1,lis0; public static void process() throws IOException { int n = sc.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 8
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
55a4ad8045a8e33bc2aac1aea30aee5b
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 EdC { static long[] mods = {1000000007, 998244353, 1000000009}; static long mod = mods[0]; public static MyScanner sc; public static PrintWriter out; public static void main(String[] havish) throws Exception{ // TODO Auto-generated method stub sc ...
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 8
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
2ac42449d21bd4825208466ae23873db
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.*; /** * Created by Brandon on 4/29/2021, 11:04 AM. */ public class Main { static long mod = 998244353; public static void solve() { // string: //char** vals = new char* [n]; //for (int i = 0; i < n; i++) { // string str = ""; // cin >> s...
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 8
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
ec935aefaa02132a84edce22611a285d
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 Main{ static int[][]memo; static int[]z,o; static int dp(int p0,int p1) { if(p1==o.length) { //all ones are matched already return 0; } if(p0==z.length) { //all zeros are finished and there is still unmatched one return 1000000000; ...
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 8
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
c8a98fe10ed58c47827b11ffa27521e7
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.math.*; import java.awt.Point; public class Main { //static final long MOD = 1000000007L; //static final long MOD2 = 1000000009L; static final long MOD = 998244353L; //static final long INF = 500000000000L; static final int INF = 100...
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 8
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
25eef509ef7afc65abd1aa00b8459545
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.text.DecimalFormat; import java.util.*; public class Main { private static final long MOD = 1000000007; private static final int MAX_VALUE = 1000000000; public static final DecimalFormat DF_2 = new DecimalFormat("0.0000"); static int[] readArray(int size, Input...
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 8
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
e7e5bca63739257b3b0de745cd65850c
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.util.stream.IntStream; public class Main { static long startTime = System.currentTimeMillis(); // for global initializations and methods starts here // global initialisations and methods end here static void run(){ boolean tc = fals...
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 8
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
f92c0dda278d294b59889e9f2e134809
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 code{ static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new ...
Java
["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 8
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
af652ca6c0132ad2a9b0d0562e0a8edf
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 Main2 { static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));} String next(){while (st == null || !st.hasMoreElements()){try{st = new S...
Java
["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 8
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
7e8a24e5f1aa6f577fde6ce43cd5ca12
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.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual...
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 8
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
58ebe40bcf186dec2087c4459bbd25ed
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 Main{ public static void main(String[] args) throws java.io.IOException { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int[] arr=new int[n]; int[][] dp=new int[n][n]; int[][] min=new int[n][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 8
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
5aab8e23ded1aff86c05230659347c8d
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.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.List; import java.util.*; public class realfast implements Runnable { private static final int INF = (int) 1e9; long in= 1000000007; long fac[]= new long[1000001]; lo...
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 8
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
b72deeb9f772ce3c47547781cc2b352c
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.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.io.BufferedOutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.InputMis...
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 8
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
c1e4d73e9237baedb49659860642f207
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 static java.lang.Math.*; public class D2 { static int[] a, b; static int[][] dp; static int x, y; static final int INF = (int) 1e9; public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.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 8
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
e51ae3e1f1dd24f566f163af52d542ee
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 Main { static Reader in = new Reader(System.in); static StringBuilder stringBuilder = new StringBuilder(); public static void main(String[] args) { int t = 1; while (t-- > 0) { int n = in.nextInt(); int[] 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 8
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
7546324820e5460f98271ed9ada2d0f9
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 static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.out; import java.util.*; import java.io.*; import java.math.*; /* getOrDefault valueOf char[] arr=st.nextToken().toCharArray(); System.out.println(); List<Integer> l...
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 17
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
8fa187e15627049a3364c7fca162e0ef
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.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class Main { private void solve(InputReader in, PrintWriter pw) { int n = in.nextInt(); int[] a = new int[n]; ArrayList<Integer> g = new ArrayList<>(); for (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 17
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
b6c05159993399b26fdcf299ebc12271
train_110.jsonl
1621152000
Monocarp plays a computer game called "Goblins and Gnomes". In this game, he manages a large underground city of gnomes and defends it from hordes of goblins.The city consists of $$$n$$$ halls and $$$m$$$ one-directional tunnels connecting them. The structure of tunnels has the following property: if a goblin leaves an...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static MyScanner scanner; public static void main(String[] args) { scanner = new MyScanner(); new Main().goblinsAndGnomes(); } private void...
Java
["5 4 4\n1 2\n2 3\n4 3\n5 3\n100 1\n200 5\n10 10\n100 1", "5 4 4\n1 2\n2 3\n4 3\n5 3\n100 100\n200 5\n10 10\n100 1", "5 10 1\n1 2\n1 3\n1 4\n1 5\n5 2\n5 3\n5 4\n4 2\n4 3\n2 3\n100 100"]
4 seconds
["6\n-2 -3 0 0 0 0", "6\n0 -3 0 0 1 0", "6\n1 2 3 4 5 0"]
NoteIn the first example, Monocarp, firstly, block all tunnels going in hall $$$2$$$, secondly — all tunnels going in hall $$$3$$$, and after that calls all waves. He spent two minutes to prepare to wave $$$1$$$, so he gets $$$98$$$ points for it. He didn't prepare after that, that's why he gets maximum scores for each...
Java 11
standard input
[ "brute force", "dp", "flows", "graph matchings" ]
3ab4973d5b1c91fb76d5c918551ba9f7
The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$; $$$0 \le m \le \frac{n(n - 1)}{2}$$$; $$$1 \le k \le n - 1$$$) — the number of halls in the city, the number of tunnels and the number of goblin waves, correspondely. Next $$$m$$$ lines describe tunnels. The $$$i$$$-th line conta...
2,800
Print the optimal Monocarp's strategy in the following format: At first, print one integer $$$a$$$ ($$$k \le a \le 2n + k$$$) — the number of actions Monocarp will perform. Next, print actions themselves in the order Monocarp performs them. The $$$i$$$-th action is described by a single integer $$$b_i$$$ ($$$-n \le b_i...
standard output
PASSED
561ba69ec34dd7e1a574dbf48597de4a
train_110.jsonl
1621152000
Monocarp plays a computer game called "Goblins and Gnomes". In this game, he manages a large underground city of gnomes and defends it from hordes of goblins.The city consists of $$$n$$$ halls and $$$m$$$ one-directional tunnels connecting them. The structure of tunnels has the following property: if a goblin leaves an...
512 megabytes
import java.io.*; import java.util.*; public class F { InputStream is; FastWriter out; String INPUT = ""; void solve() { int n = ni(), m = ni(), K = ni(); boolean[][] g = new boolean[n][n]; long ina = 0; long outa = 0; for(int i = 0;i < m;i++){ int a = ni()-1, b = ni()-1; g[a][...
Java
["5 4 4\n1 2\n2 3\n4 3\n5 3\n100 1\n200 5\n10 10\n100 1", "5 4 4\n1 2\n2 3\n4 3\n5 3\n100 100\n200 5\n10 10\n100 1", "5 10 1\n1 2\n1 3\n1 4\n1 5\n5 2\n5 3\n5 4\n4 2\n4 3\n2 3\n100 100"]
4 seconds
["6\n-2 -3 0 0 0 0", "6\n0 -3 0 0 1 0", "6\n1 2 3 4 5 0"]
NoteIn the first example, Monocarp, firstly, block all tunnels going in hall $$$2$$$, secondly — all tunnels going in hall $$$3$$$, and after that calls all waves. He spent two minutes to prepare to wave $$$1$$$, so he gets $$$98$$$ points for it. He didn't prepare after that, that's why he gets maximum scores for each...
Java 11
standard input
[ "brute force", "dp", "flows", "graph matchings" ]
3ab4973d5b1c91fb76d5c918551ba9f7
The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$; $$$0 \le m \le \frac{n(n - 1)}{2}$$$; $$$1 \le k \le n - 1$$$) — the number of halls in the city, the number of tunnels and the number of goblin waves, correspondely. Next $$$m$$$ lines describe tunnels. The $$$i$$$-th line conta...
2,800
Print the optimal Monocarp's strategy in the following format: At first, print one integer $$$a$$$ ($$$k \le a \le 2n + k$$$) — the number of actions Monocarp will perform. Next, print actions themselves in the order Monocarp performs them. The $$$i$$$-th action is described by a single integer $$$b_i$$$ ($$$-n \le b_i...
standard output
PASSED
61253c78af366d4c2ab37419bed38c35
train_110.jsonl
1621152000
Monocarp plays a computer game called "Goblins and Gnomes". In this game, he manages a large underground city of gnomes and defends it from hordes of goblins.The city consists of $$$n$$$ halls and $$$m$$$ one-directional tunnels connecting them. The structure of tunnels has the following property: if a goblin leaves an...
512 megabytes
import java.io.*; import java.util.*; public class F { InputStream is; FastWriter out; String INPUT = ""; void solve() { int n = ni(), m = ni(), K = ni(); boolean[][] g = new boolean[n][n]; long ina = 0; long outa = 0; for(int i = 0;i < m;i++){ int a = ni()-1, b = ni()-1; g[a][...
Java
["5 4 4\n1 2\n2 3\n4 3\n5 3\n100 1\n200 5\n10 10\n100 1", "5 4 4\n1 2\n2 3\n4 3\n5 3\n100 100\n200 5\n10 10\n100 1", "5 10 1\n1 2\n1 3\n1 4\n1 5\n5 2\n5 3\n5 4\n4 2\n4 3\n2 3\n100 100"]
4 seconds
["6\n-2 -3 0 0 0 0", "6\n0 -3 0 0 1 0", "6\n1 2 3 4 5 0"]
NoteIn the first example, Monocarp, firstly, block all tunnels going in hall $$$2$$$, secondly — all tunnels going in hall $$$3$$$, and after that calls all waves. He spent two minutes to prepare to wave $$$1$$$, so he gets $$$98$$$ points for it. He didn't prepare after that, that's why he gets maximum scores for each...
Java 11
standard input
[ "brute force", "dp", "flows", "graph matchings" ]
3ab4973d5b1c91fb76d5c918551ba9f7
The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$; $$$0 \le m \le \frac{n(n - 1)}{2}$$$; $$$1 \le k \le n - 1$$$) — the number of halls in the city, the number of tunnels and the number of goblin waves, correspondely. Next $$$m$$$ lines describe tunnels. The $$$i$$$-th line conta...
2,800
Print the optimal Monocarp's strategy in the following format: At first, print one integer $$$a$$$ ($$$k \le a \le 2n + k$$$) — the number of actions Monocarp will perform. Next, print actions themselves in the order Monocarp performs them. The $$$i$$$-th action is described by a single integer $$$b_i$$$ ($$$-n \le b_i...
standard output
PASSED
1c9edae212e17a14471c10e0781a9146
train_110.jsonl
1621152000
Monocarp plays a computer game called "Goblins and Gnomes". In this game, he manages a large underground city of gnomes and defends it from hordes of goblins.The city consists of $$$n$$$ halls and $$$m$$$ one-directional tunnels connecting them. The structure of tunnels has the following property: if a goblin leaves an...
512 megabytes
//package ecr109; import java.io.*; import java.util.*; public class F { InputStream is; FastWriter out; String INPUT = ""; void solve() { int n = ni(), m = ni(), K = ni(); boolean[][] g = new boolean[n][n]; long ina = 0; long outa = 0; for(int i = 0;i < m;i++){ int a = ni()-1, b = ...
Java
["5 4 4\n1 2\n2 3\n4 3\n5 3\n100 1\n200 5\n10 10\n100 1", "5 4 4\n1 2\n2 3\n4 3\n5 3\n100 100\n200 5\n10 10\n100 1", "5 10 1\n1 2\n1 3\n1 4\n1 5\n5 2\n5 3\n5 4\n4 2\n4 3\n2 3\n100 100"]
4 seconds
["6\n-2 -3 0 0 0 0", "6\n0 -3 0 0 1 0", "6\n1 2 3 4 5 0"]
NoteIn the first example, Monocarp, firstly, block all tunnels going in hall $$$2$$$, secondly — all tunnels going in hall $$$3$$$, and after that calls all waves. He spent two minutes to prepare to wave $$$1$$$, so he gets $$$98$$$ points for it. He didn't prepare after that, that's why he gets maximum scores for each...
Java 11
standard input
[ "brute force", "dp", "flows", "graph matchings" ]
3ab4973d5b1c91fb76d5c918551ba9f7
The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$; $$$0 \le m \le \frac{n(n - 1)}{2}$$$; $$$1 \le k \le n - 1$$$) — the number of halls in the city, the number of tunnels and the number of goblin waves, correspondely. Next $$$m$$$ lines describe tunnels. The $$$i$$$-th line conta...
2,800
Print the optimal Monocarp's strategy in the following format: At first, print one integer $$$a$$$ ($$$k \le a \le 2n + k$$$) — the number of actions Monocarp will perform. Next, print actions themselves in the order Monocarp performs them. The $$$i$$$-th action is described by a single integer $$$b_i$$$ ($$$-n \le b_i...
standard output
PASSED
b4f8a8be58e8d919db9bfc4972ae7f88
train_110.jsonl
1621152000
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.Monocarp's empire has $$$n$$$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one M...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class e1525 { public static void main(String[] args) { Scanner s = new Scanner(System.in); init(20); solve(s.nextInt(), s.nextInt(), s); } static long fact[]; static void init(int l) { fact = ne...
Java
["3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3"]
2 seconds
["166374062"]
NoteLet's look at all possible orders of cities Monuments will be build in: $$$[1, 2, 3]$$$: the first city controls all points at distance at most $$$3$$$, in other words, points $$$1$$$ and $$$4$$$; the second city controls all points at distance at most $$$2$$$, or points $$$1$$$, $$$3$$$ and $$$5$$$; the thir...
Java 11
standard input
[ "combinatorics", "dp", "math", "probabilities", "two pointers" ]
81f709b914ca1821b254f07b2464fbf2
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 20$$$; $$$1 \le m \le 5 \cdot 10^4$$$) — the number of cities and the number of points. Next $$$n$$$ lines contains $$$m$$$ integers each: the $$$j$$$-th integer of the $$$i$$$-th line $$$d_{i, j}$$$ ($$$1 \le d_{i, j} \le n + 1$$$) is the distanc...
2,100
It can be shown that the expected number of points Monocarp conquers at the end of the $$$n$$$-th turn can be represented as an irreducible fraction $$$\frac{x}{y}$$$. Print this fraction modulo $$$998\,244\,353$$$, i. e. value $$$x \cdot y^{-1} \bmod 998244353$$$ where $$$y^{-1}$$$ is such number that $$$y \cdot y^{-1...
standard output
PASSED
564383fed234dbd01599aab7ba562983
train_110.jsonl
1621152000
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.Monocarp's empire has $$$n$$$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one M...
256 megabytes
import java.math.BigInteger; import java.util.*; import java.io.*; public class Div716 { static int n, m, a[][]; static int mod = 998244353; static long[] fact; static long[] inv; static void preprocess() { fact = new long[n + 1]; inv = new long[n + 1]; fact[...
Java
["3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3"]
2 seconds
["166374062"]
NoteLet's look at all possible orders of cities Monuments will be build in: $$$[1, 2, 3]$$$: the first city controls all points at distance at most $$$3$$$, in other words, points $$$1$$$ and $$$4$$$; the second city controls all points at distance at most $$$2$$$, or points $$$1$$$, $$$3$$$ and $$$5$$$; the thir...
Java 11
standard input
[ "combinatorics", "dp", "math", "probabilities", "two pointers" ]
81f709b914ca1821b254f07b2464fbf2
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 20$$$; $$$1 \le m \le 5 \cdot 10^4$$$) — the number of cities and the number of points. Next $$$n$$$ lines contains $$$m$$$ integers each: the $$$j$$$-th integer of the $$$i$$$-th line $$$d_{i, j}$$$ ($$$1 \le d_{i, j} \le n + 1$$$) is the distanc...
2,100
It can be shown that the expected number of points Monocarp conquers at the end of the $$$n$$$-th turn can be represented as an irreducible fraction $$$\frac{x}{y}$$$. Print this fraction modulo $$$998\,244\,353$$$, i. e. value $$$x \cdot y^{-1} \bmod 998244353$$$ where $$$y^{-1}$$$ is such number that $$$y \cdot y^{-1...
standard output
PASSED
16c9499f7da3c09f301e356c634b3211
train_110.jsonl
1621152000
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.Monocarp's empire has $$$n$$$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one M...
256 megabytes
import java.util.*; import java.io.*; public class Sol{ static InputStream inputStream = System.in; static OutputStream outputStream = System.out; static FastReader in=new FastReader(inputStream); static PrintWriter out=new PrintWriter(outputStream); static class FastReader { BufferedReader br; Str...
Java
["3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3"]
2 seconds
["166374062"]
NoteLet's look at all possible orders of cities Monuments will be build in: $$$[1, 2, 3]$$$: the first city controls all points at distance at most $$$3$$$, in other words, points $$$1$$$ and $$$4$$$; the second city controls all points at distance at most $$$2$$$, or points $$$1$$$, $$$3$$$ and $$$5$$$; the thir...
Java 11
standard input
[ "combinatorics", "dp", "math", "probabilities", "two pointers" ]
81f709b914ca1821b254f07b2464fbf2
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 20$$$; $$$1 \le m \le 5 \cdot 10^4$$$) — the number of cities and the number of points. Next $$$n$$$ lines contains $$$m$$$ integers each: the $$$j$$$-th integer of the $$$i$$$-th line $$$d_{i, j}$$$ ($$$1 \le d_{i, j} \le n + 1$$$) is the distanc...
2,100
It can be shown that the expected number of points Monocarp conquers at the end of the $$$n$$$-th turn can be represented as an irreducible fraction $$$\frac{x}{y}$$$. Print this fraction modulo $$$998\,244\,353$$$, i. e. value $$$x \cdot y^{-1} \bmod 998244353$$$ where $$$y^{-1}$$$ is such number that $$$y \cdot y^{-1...
standard output
PASSED
a9fbe5de67f234b59620eb04e5d00e03
train_110.jsonl
1621152000
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.Monocarp's empire has $$$n$$$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one M...
256 megabytes
import java.io.DataInputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; public class Main { private static void run() throws IOException { int n = in.nextInt(); int m = in.nextInt(); int[][] a = new int[m][n]; ...
Java
["3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3"]
2 seconds
["166374062"]
NoteLet's look at all possible orders of cities Monuments will be build in: $$$[1, 2, 3]$$$: the first city controls all points at distance at most $$$3$$$, in other words, points $$$1$$$ and $$$4$$$; the second city controls all points at distance at most $$$2$$$, or points $$$1$$$, $$$3$$$ and $$$5$$$; the thir...
Java 11
standard input
[ "combinatorics", "dp", "math", "probabilities", "two pointers" ]
81f709b914ca1821b254f07b2464fbf2
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 20$$$; $$$1 \le m \le 5 \cdot 10^4$$$) — the number of cities and the number of points. Next $$$n$$$ lines contains $$$m$$$ integers each: the $$$j$$$-th integer of the $$$i$$$-th line $$$d_{i, j}$$$ ($$$1 \le d_{i, j} \le n + 1$$$) is the distanc...
2,100
It can be shown that the expected number of points Monocarp conquers at the end of the $$$n$$$-th turn can be represented as an irreducible fraction $$$\frac{x}{y}$$$. Print this fraction modulo $$$998\,244\,353$$$, i. e. value $$$x \cdot y^{-1} \bmod 998244353$$$ where $$$y^{-1}$$$ is such number that $$$y \cdot y^{-1...
standard output
PASSED
c2a458b05936deb8f761f942ecf47a93
train_110.jsonl
1621152000
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.Monocarp's empire has $$$n$$$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one M...
256 megabytes
import java.io.*; import java.util.*; public class E1525 { public static void main(String[] args) throws IOException, FileNotFoundException { // Scanner in = new Scanner(new File("test.in")); Kattio in = new Kattio(); int N = in.nextInt(); int M = in.nextInt(); int[][] dist...
Java
["3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3"]
2 seconds
["166374062"]
NoteLet's look at all possible orders of cities Monuments will be build in: $$$[1, 2, 3]$$$: the first city controls all points at distance at most $$$3$$$, in other words, points $$$1$$$ and $$$4$$$; the second city controls all points at distance at most $$$2$$$, or points $$$1$$$, $$$3$$$ and $$$5$$$; the thir...
Java 11
standard input
[ "combinatorics", "dp", "math", "probabilities", "two pointers" ]
81f709b914ca1821b254f07b2464fbf2
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 20$$$; $$$1 \le m \le 5 \cdot 10^4$$$) — the number of cities and the number of points. Next $$$n$$$ lines contains $$$m$$$ integers each: the $$$j$$$-th integer of the $$$i$$$-th line $$$d_{i, j}$$$ ($$$1 \le d_{i, j} \le n + 1$$$) is the distanc...
2,100
It can be shown that the expected number of points Monocarp conquers at the end of the $$$n$$$-th turn can be represented as an irreducible fraction $$$\frac{x}{y}$$$. Print this fraction modulo $$$998\,244\,353$$$, i. e. value $$$x \cdot y^{-1} \bmod 998244353$$$ where $$$y^{-1}$$$ is such number that $$$y \cdot y^{-1...
standard output
PASSED
adba7aeb1425137283a5d24c8faaea93
train_110.jsonl
1621152000
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.Monocarp's empire has $$$n$$$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one M...
256 megabytes
import java.io.DataInputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; public class Main { private static void run() throws IOException { int n = in.nextInt(); int m = in.nextInt(); int[][] a = new int[...
Java
["3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3"]
2 seconds
["166374062"]
NoteLet's look at all possible orders of cities Monuments will be build in: $$$[1, 2, 3]$$$: the first city controls all points at distance at most $$$3$$$, in other words, points $$$1$$$ and $$$4$$$; the second city controls all points at distance at most $$$2$$$, or points $$$1$$$, $$$3$$$ and $$$5$$$; the thir...
Java 11
standard input
[ "combinatorics", "dp", "math", "probabilities", "two pointers" ]
81f709b914ca1821b254f07b2464fbf2
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 20$$$; $$$1 \le m \le 5 \cdot 10^4$$$) — the number of cities and the number of points. Next $$$n$$$ lines contains $$$m$$$ integers each: the $$$j$$$-th integer of the $$$i$$$-th line $$$d_{i, j}$$$ ($$$1 \le d_{i, j} \le n + 1$$$) is the distanc...
2,100
It can be shown that the expected number of points Monocarp conquers at the end of the $$$n$$$-th turn can be represented as an irreducible fraction $$$\frac{x}{y}$$$. Print this fraction modulo $$$998\,244\,353$$$, i. e. value $$$x \cdot y^{-1} \bmod 998244353$$$ where $$$y^{-1}$$$ is such number that $$$y \cdot y^{-1...
standard output
PASSED
52cae434f2f4380a53099040ae883784
train_110.jsonl
1621152000
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.Monocarp's empire has $$$n$$$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one M...
256 megabytes
import java.util.*; import java.io.*; public class _1525_E { static long MOD = 998244353; static long[] fact = new long[25]; static long[] inv_fact = new long[25]; public static void main(String[] args) throws IOException { fact[0] = 1; inv_fact[0] = 1; for(int i = 1; ...
Java
["3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3"]
2 seconds
["166374062"]
NoteLet's look at all possible orders of cities Monuments will be build in: $$$[1, 2, 3]$$$: the first city controls all points at distance at most $$$3$$$, in other words, points $$$1$$$ and $$$4$$$; the second city controls all points at distance at most $$$2$$$, or points $$$1$$$, $$$3$$$ and $$$5$$$; the thir...
Java 11
standard input
[ "combinatorics", "dp", "math", "probabilities", "two pointers" ]
81f709b914ca1821b254f07b2464fbf2
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 20$$$; $$$1 \le m \le 5 \cdot 10^4$$$) — the number of cities and the number of points. Next $$$n$$$ lines contains $$$m$$$ integers each: the $$$j$$$-th integer of the $$$i$$$-th line $$$d_{i, j}$$$ ($$$1 \le d_{i, j} \le n + 1$$$) is the distanc...
2,100
It can be shown that the expected number of points Monocarp conquers at the end of the $$$n$$$-th turn can be represented as an irreducible fraction $$$\frac{x}{y}$$$. Print this fraction modulo $$$998\,244\,353$$$, i. e. value $$$x \cdot y^{-1} \bmod 998244353$$$ where $$$y^{-1}$$$ is such number that $$$y \cdot y^{-1...
standard output
PASSED
5bc0b179ab4a016a4928e15dba80ef5a
train_110.jsonl
1621152000
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.Monocarp's empire has $$$n$$$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one M...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; import java.io.File; import java.io.FileDescriptor; import java.io.FileOutputStream; import java.io.OutputStream; import java.io.UncheckedIOExcept...
Java
["3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3"]
2 seconds
["166374062"]
NoteLet's look at all possible orders of cities Monuments will be build in: $$$[1, 2, 3]$$$: the first city controls all points at distance at most $$$3$$$, in other words, points $$$1$$$ and $$$4$$$; the second city controls all points at distance at most $$$2$$$, or points $$$1$$$, $$$3$$$ and $$$5$$$; the thir...
Java 11
standard input
[ "combinatorics", "dp", "math", "probabilities", "two pointers" ]
81f709b914ca1821b254f07b2464fbf2
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 20$$$; $$$1 \le m \le 5 \cdot 10^4$$$) — the number of cities and the number of points. Next $$$n$$$ lines contains $$$m$$$ integers each: the $$$j$$$-th integer of the $$$i$$$-th line $$$d_{i, j}$$$ ($$$1 \le d_{i, j} \le n + 1$$$) is the distanc...
2,100
It can be shown that the expected number of points Monocarp conquers at the end of the $$$n$$$-th turn can be represented as an irreducible fraction $$$\frac{x}{y}$$$. Print this fraction modulo $$$998\,244\,353$$$, i. e. value $$$x \cdot y^{-1} \bmod 998244353$$$ where $$$y^{-1}$$$ is such number that $$$y \cdot y^{-1...
standard output
PASSED
2eb7d85d4904e17cf877167fb871f270
train_110.jsonl
1621152000
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.Monocarp's empire has $$$n$$$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one M...
256 megabytes
import java.io.*; import java.util.*; public class Contest1525E { static class InputReader { BufferedReader reader; StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } String next() { // ...
Java
["3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3"]
2 seconds
["166374062"]
NoteLet's look at all possible orders of cities Monuments will be build in: $$$[1, 2, 3]$$$: the first city controls all points at distance at most $$$3$$$, in other words, points $$$1$$$ and $$$4$$$; the second city controls all points at distance at most $$$2$$$, or points $$$1$$$, $$$3$$$ and $$$5$$$; the thir...
Java 11
standard input
[ "combinatorics", "dp", "math", "probabilities", "two pointers" ]
81f709b914ca1821b254f07b2464fbf2
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 20$$$; $$$1 \le m \le 5 \cdot 10^4$$$) — the number of cities and the number of points. Next $$$n$$$ lines contains $$$m$$$ integers each: the $$$j$$$-th integer of the $$$i$$$-th line $$$d_{i, j}$$$ ($$$1 \le d_{i, j} \le n + 1$$$) is the distanc...
2,100
It can be shown that the expected number of points Monocarp conquers at the end of the $$$n$$$-th turn can be represented as an irreducible fraction $$$\frac{x}{y}$$$. Print this fraction modulo $$$998\,244\,353$$$, i. e. value $$$x \cdot y^{-1} \bmod 998244353$$$ where $$$y^{-1}$$$ is such number that $$$y \cdot y^{-1...
standard output