Codeforces Round 879 (Div. 2)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1834 Codeforces Round 879 (Div. 2) FINISHED False 7200 44747699 June 18, 2023, 8:05 a.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 25207 ) A Unit Array PROGRAMMING greedy math

B"Given an array a of length n , which elements are equal to -1 and 1 . Let's call the array a good if the following conditions are held at the same time: In one operation, you can select an arbitrary element of the array a_i and change its value to the opposite. In other words, if a_i = -1 , you can assign the value to a_i := 1 , and if a_i = 1 , then assign the value to a_i := -1 . Determine the minimum number of operations you need to perform to make the array a good. It can be shown that this is always possible. Each test consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 500 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 100 ) -- the length of the array a . The second line of each test case contains n integers a_1, a_2, ldots, a_n ( a_i = pm 1 ) -- the elements of the array a . For each test case, output a single integer -- the minimum number of operations that need to be done to make the a array good. In the first test case, we can assign the value a_1 := 1 . Then a_1 + a_2 + a_3 + a_4 = 1 + (-1) + 1 + (-1) = 0 ge 0 and a_1 cdot a_2 cdot a_3 cdot a_4 = 1 cdot (-1) cdot 1 cdot (-1) = 1 . Thus, we performed 1 operation. In the second test case, we can assign a_1 := 1 . Then a_1 + a_2 + a_3 + a_4 + a_5 = 1 + (-1) + (-1) + 1 + 1 = 1 ge 0 and a_1 cdot a_2 cdot a_3 cdot a_4 cdot a_5 = 1 cdot (-1) cdot (-1) cdot 1 cdot 1 = 1 . Thus, we performed 1 operation. In the third test case, a_1 + a_2 + a_3 + a_4 = (-1) + 1 + (-1) + 1 = 0 ge 0 and a_1 cdot a_2 cdot a_3 cdot a_4 = (-1) cdot 1 cdot (-1) cdot 1 = 1 . Thus, all conditions are already satisfied and no operations are needed. In the fourth test case, we can assign the values "...

Tutorials

Codeforces Round #879 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
210102502 bluemegane A June 18, 2023, 1:16 p.m. OK C# 8 TESTS 5 93 2355200
210126896 ayush_2318 A June 18, 2023, 3 p.m. OK Clang++17 Diagnostics TESTS 5 155 1024000
210182611 Shiho_Miyano A June 18, 2023, 8:15 p.m. OK Clang++20 Diagnostics TESTS 5 156 0
210088310 KEVl A June 18, 2023, 10:46 a.m. OK FPC TESTS 5 30 0
210083686 nightfury02 A June 18, 2023, 10:17 a.m. OK GNU C11 TESTS 5 15 0
210084194 Manasa1306 A June 18, 2023, 10:19 a.m. OK GNU C11 TESTS 5 15 0
210091599 shashank_padamati A June 18, 2023, 11:17 a.m. OK GNU C11 TESTS 5 15 0
210107450 abbccd A June 18, 2023, 2:11 p.m. OK GNU C11 TESTS 5 15 0
210075487 Pavani_Penumalla A June 18, 2023, 9:44 a.m. OK GNU C11 TESTS 5 15 0
210081764 lakshman877 A June 18, 2023, 10:02 a.m. OK GNU C11 TESTS 5 15 0
210077629 sanjaynelli A June 18, 2023, 9:50 a.m. OK GNU C11 TESTS 5 30 0
210091771 sumonsnr A June 18, 2023, 11:19 a.m. OK GNU C11 TESTS 5 31 0
210074699 rohittanuku03 A June 18, 2023, 9:41 a.m. OK GNU C11 TESTS 5 31 0
210086781 Bai_xiaobo A June 18, 2023, 10:34 a.m. OK GNU C++14 TESTS 5 0 0
210088520 broCoder07 A June 18, 2023, 10:48 a.m. OK GNU C++14 TESTS 5 0 0
210087083 0xessam A June 18, 2023, 10:36 a.m. OK GNU C++14 TESTS 5 0 0
210107882 everyday48 A June 18, 2023, 2:15 p.m. OK GNU C++14 TESTS 5 0 0
210188930 zltzlt A June 18, 2023, 11:11 p.m. OK GNU C++14 TESTS 5 0 0
210193314 yuezheng A June 19, 2023, 1:40 a.m. OK GNU C++14 TESTS 5 0 0
210205975 iamv1n A June 19, 2023, 5:57 a.m. OK GNU C++14 TESTS 5 0 102400
210205412 lhr_rotate A June 19, 2023, 5:47 a.m. OK GNU C++14 TESTS 5 0 4505600
210198435 _steelbenze_ A June 19, 2023, 3:38 a.m. OK GNU C++14 TESTS 5 15 0
210202313 BrotherCall A June 19, 2023, 4:52 a.m. OK GNU C++14 TESTS 5 15 0
210130395 arin_nigam A June 18, 2023, 3:07 p.m. OK GNU C++17 TESTS 5 0 0
210168765 abdullah__92 A June 18, 2023, 5:15 p.m. OK GNU C++17 TESTS 5 0 0
210170068 _s.r.i.j.a.l_ A June 18, 2023, 5:24 p.m. OK GNU C++17 TESTS 5 0 0
210175525 m.gado A June 18, 2023, 6:21 p.m. OK GNU C++17 TESTS 5 0 0
210182073 _ahd_ahmed_ A June 18, 2023, 8:05 p.m. OK GNU C++17 TESTS 5 0 0
210184043 FireByMisFire A June 18, 2023, 8:43 p.m. OK GNU C++17 TESTS 5 0 0
210193450 ARUME A June 19, 2023, 1:43 a.m. OK GNU C++17 TESTS 5 0 0
210195546 Yeaish_Turj A June 19, 2023, 2:34 a.m. OK GNU C++17 TESTS 5 0 0
210195859 Tony1234 A June 19, 2023, 2:41 a.m. OK GNU C++17 TESTS 5 0 0
210168410 BADHON30 A June 18, 2023, 5:12 p.m. OK GNU C++17 TESTS 5 0 0
210083947 459045 A June 18, 2023, 10:18 a.m. OK GNU C++17 (64) TESTS 5 0 0
210176839 hacker_antace A June 18, 2023, 6:37 p.m. OK GNU C++17 (64) TESTS 5 0 0
210097926 InHng A June 18, 2023, 12:23 p.m. OK GNU C++17 (64) TESTS 5 0 0
210094890 Ahmed_Salah A June 18, 2023, 11:52 a.m. OK GNU C++17 (64) TESTS 5 0 0
210085955 gqf123 A June 18, 2023, 10:29 a.m. OK GNU C++17 (64) TESTS 5 0 0
210084763 Once_I_Liked_AGirl A June 18, 2023, 10:21 a.m. OK GNU C++17 (64) TESTS 5 0 0
210084347 HelmOptimum A June 18, 2023, 10:19 a.m. OK GNU C++17 (64) TESTS 5 0 0
210083830 Mag1sk A June 18, 2023, 10:17 a.m. OK GNU C++17 (64) TESTS 5 0 0
210085473 wcdr A June 18, 2023, 10:25 a.m. OK GNU C++17 (64) TESTS 5 0 204800
210206160 202003027 A June 19, 2023, 6 a.m. OK GNU C++17 (64) TESTS 5 15 0
210180133 yrohitp A June 18, 2023, 7:30 p.m. OK GNU C++20 (64) TESTS 5 0 0
210187593 ItachiUchiha8 A June 18, 2023, 10:22 p.m. OK GNU C++20 (64) TESTS 5 0 0
210191493 Uchiha_Itachii A June 19, 2023, 12:45 a.m. OK GNU C++20 (64) TESTS 5 0 0
210191944 muhammadhasan01 A June 19, 2023, 12:59 a.m. OK GNU C++20 (64) TESTS 5 0 0
210195870 pipipipipi43 A June 19, 2023, 2:42 a.m. OK GNU C++20 (64) TESTS 5 0 0
210197266 sweet_hope25 A June 19, 2023, 3:13 a.m. OK GNU C++20 (64) TESTS 5 0 0
210197664 MrDeeb A June 19, 2023, 3:22 a.m. OK GNU C++20 (64) TESTS 5 0 0
210201772 dimss A June 19, 2023, 4:41 a.m. OK GNU C++20 (64) TESTS 5 0 0
210185522 ammaraglan6 A June 18, 2023, 9:17 p.m. OK GNU C++20 (64) TESTS 5 0 0
210180502 KareemHatem A June 18, 2023, 7:36 p.m. OK GNU C++20 (64) TESTS 5 0 0
210194080 cck111 A June 19, 2023, 1:59 a.m. OK Go TESTS 5 15 0
210101840 GenFPS A June 18, 2023, 1:08 p.m. OK Go TESTS 5 342 3481600
210101695 GenFPS A June 18, 2023, 1:06 p.m. OK Go TESTS 5 389 3481600
210205786 chunqiu.ssh A June 19, 2023, 5:53 a.m. OK Java 11 TESTS 5 186 0
210167950 Awes19 A June 18, 2023, 5:10 p.m. OK Java 11 TESTS 5 202 0
210166507 MuhammD_husss A June 18, 2023, 4:52 p.m. OK Java 11 TESTS 5 202 0
210088359 c4pt41n A June 18, 2023, 10:46 a.m. OK Java 11 TESTS 5 217 0
210085219 _Ov3rlord_ A June 18, 2023, 10:24 a.m. OK Java 11 TESTS 5 217 0
210121918 vasanthirudra A June 18, 2023, 2:51 p.m. OK Java 11 TESTS 5 218 0
210099172 cptraveller A June 18, 2023, 12:37 p.m. OK Java 11 TESTS 5 218 0
210183166 saksham19270 A June 18, 2023, 8:27 p.m. OK Java 11 TESTS 5 233 0
210084860 Alone_28 A June 18, 2023, 10:22 a.m. OK Java 11 TESTS 5 233 0
210081422 2100030389cseh A June 18, 2023, 10:01 a.m. OK Java 11 TESTS 5 248 0
210099441 rated21 A June 18, 2023, 12:40 p.m. OK Java 17 TESTS 5 156 614400
210183523 mansurzq A June 18, 2023, 8:32 p.m. OK Java 17 TESTS 5 170 0
210090425 Hsharma A June 18, 2023, 11:05 a.m. OK Java 17 TESTS 5 171 307200
210099521 rated21 A June 18, 2023, 12:41 p.m. OK Java 17 TESTS 5 171 614400
210166678 aishwarykesarwani A June 18, 2023, 4:55 p.m. OK Java 17 TESTS 5 187 0
210090865 vikash_45 A June 18, 2023, 11:09 a.m. OK Java 17 TESTS 5 187 307200
210183828 craddles A June 18, 2023, 8:38 p.m. OK Java 17 TESTS 5 187 512000
210168791 dakshkhullar14 A June 18, 2023, 5:15 p.m. OK Java 17 TESTS 5 202 0
210094866 wintersoldier2004 A June 18, 2023, 11:52 a.m. OK Java 17 TESTS 5 202 102400
210156485 Ayyylmao A June 18, 2023, 4:11 p.m. OK Java 17 TESTS 5 202 409600
210152271 DingYigui A June 18, 2023, 3:59 p.m. OK Java 8 TESTS 5 93 0
210146499 DingYigui A June 18, 2023, 3:43 p.m. OK Java 8 TESTS 5 93 0
210092974 priyaroy3370 A June 18, 2023, 11:32 a.m. OK Java 8 TESTS 5 93 0
210091393 Sanat04 A June 18, 2023, 11:15 a.m. OK Java 8 TESTS 5 93 0
210101902 tejasS-27 A June 18, 2023, 1:09 p.m. OK Java 8 TESTS 5 109 0
210086463 Sumitsingh7 A June 18, 2023, 10:32 a.m. OK Java 8 TESTS 5 109 5836800
210205377 Juhaied_nabid A June 19, 2023, 5:47 a.m. OK Java 8 TESTS 5 124 0
210098013 quantummaniac609 A June 18, 2023, 12:24 p.m. OK Java 8 TESTS 5 124 0
210096902 depurador_ik A June 18, 2023, 12:13 p.m. OK Java 8 TESTS 5 124 38195200
210089123 bleach__ A June 18, 2023, 10:53 a.m. OK Java 8 TESTS 5 139 46284800
210129481 SlavaG A June 18, 2023, 3:05 p.m. OK Kotlin 1.7 TESTS 5 311 5017600
210103932 rudolf A June 18, 2023, 1:34 p.m. OK Kotlin 1.7 TESTS 5 499 60108800
210078490 Tadek_Win A June 18, 2023, 9:53 a.m. OK MS C++ 2017 TESTS 5 15 0
210144417 Mingshaozii A June 18, 2023, 3:38 p.m. OK MS C++ 2017 TESTS 5 31 0
210109535 ashwarya240 A June 18, 2023, 2:31 p.m. OK MS C++ 2017 TESTS 5 31 0
210108908 magician_Y A June 18, 2023, 2:25 p.m. OK MS C++ 2017 TESTS 5 31 0
210098997 huashiweiying A June 18, 2023, 12:35 p.m. OK MS C++ 2017 TESTS 5 31 0
210082459 Aayush_Kumar_Singh A June 18, 2023, 10:04 a.m. OK MS C++ 2017 TESTS 5 31 0
210078890 daoyi492 A June 18, 2023, 9:54 a.m. OK MS C++ 2017 TESTS 5 31 0
210176585 varrick A June 18, 2023, 6:34 p.m. OK Ocaml TESTS 5 15 204800
210092921 jvatsal0709 A June 18, 2023, 11:31 a.m. OK PyPy 3 TESTS 5 93 1945600
210097098 pennymagic156 A June 18, 2023, 12:15 p.m. OK PyPy 3 TESTS 5 108 2048000
210200644 ashmit-453 A June 19, 2023, 4:16 a.m. OK PyPy 3 TESTS 5 108 2355200
210094905 call_me_atul A June 18, 2023, 11:52 a.m. OK PyPy 3 TESTS 5 139 3788800
210107119 abbccd A June 18, 2023, 2:07 p.m. OK PyPy 3 TESTS 5 140 3788800
210178586 gardengnome A June 18, 2023, 7:04 p.m. OK PyPy 3-64 TESTS 5 61 2048000
210086113 tnv2004 A June 18, 2023, 10:30 a.m. OK PyPy 3-64 TESTS 5 61 3174400
210192600 carol5s A June 19, 2023, 1:17 a.m. OK PyPy 3-64 TESTS 5 62 1843200
210196914 AB27 A June 19, 2023, 3:06 a.m. OK PyPy 3-64 TESTS 5 77 1945600
210197013 nealzane A June 19, 2023, 3:08 a.m. OK PyPy 3-64 TESTS 5 77 2560000
210109041 abhijeet.panihar.cse20 A June 18, 2023, 2:26 p.m. OK PyPy 3-64 TESTS 5 77 2764800
210186549 lpychemistry A June 18, 2023, 9:49 p.m. OK PyPy 3-64 TESTS 5 77 2969600
210086205 tnv2004 A June 18, 2023, 10:30 a.m. OK PyPy 3-64 TESTS 5 77 3174400
210195554 momochi003 A June 19, 2023, 2:34 a.m. OK PyPy 3-64 TESTS 5 77 3584000
210098766 Youarenotgood A June 18, 2023, 12:33 p.m. OK PyPy 3-64 TESTS 5 77 4198400
210174786 rawwar A June 18, 2023, 6:12 p.m. OK Python 3 TESTS 5 31 0
210109409 XanderChou A June 18, 2023, 2:30 p.m. OK Python 3 TESTS 5 31 0
210094421 shashwat22473 A June 18, 2023, 11:47 a.m. OK Python 3 TESTS 5 31 0
210110941 asinha A June 18, 2023, 2:38 p.m. OK Python 3 TESTS 5 31 307200
210091915 kanth_7 A June 18, 2023, 11:21 a.m. OK Python 3 TESTS 5 31 512000
210204437 vadimsimakin A June 19, 2023, 5:31 a.m. OK Python 3 TESTS 5 46 0
210188290 dritekshanvarma4 A June 18, 2023, 10:45 p.m. OK Python 3 TESTS 5 46 0
210177894 sheriff1231 A June 18, 2023, 6:53 p.m. OK Python 3 TESTS 5 46 0
210175784 Riyajulhasan A June 18, 2023, 6:25 p.m. OK Python 3 TESTS 5 46 0
210168009 OzodbekX A June 18, 2023, 5:10 p.m. OK Python 3 TESTS 5 46 0
210187792 0x81 A June 18, 2023, 10:28 p.m. OK Ruby 3 TESTS 5 233 0

remove filters

Back to search problems