Codeforces Round 324 (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
584 Codeforces Round 324 (Div. 2) FINISHED False 7200 287674199 Oct. 6, 2015, 4:30 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1428 ) E Anton and Ira PROGRAMMING constructive algorithms greedy math 2400

B"Anton loves transforming one permutation into another one by swapping elements for money, and Ira doesn't like paying for stupid games. Help them obtain the required permutation by paying as little money as possible. More formally, we have two permutations, p and s of numbers from 1 to n. We can swap pi and pj, by paying |i xe2 x80 x89- xe2 x80 x89j| coins for it. Find and print the smallest number of coins required to obtain permutation s from permutation p. Also print the sequence of swap operations at which we obtain a solution. The first line contains a single number n (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x892000) -- the length of the permutations. The second line contains a sequence of n numbers from 1 to n -- permutation p. Each number from 1 to n occurs exactly once in this line. The third line contains a sequence of n numbers from 1 to n -- permutation s. Each number from 1 to n occurs once in this line. In the first line print the minimum number of coins that you need to spend to transform permutation p into permutation s. In the second line print number k (0 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89k xe2 x80 x89 xe2 x89 xa4 xe2 x80 x892 xc2 xb7106) -- the number of operations needed to get the solution. In the next k lines print the operations. Each line must contain two numbers i and j (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89i, xe2 x80 x89j xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, i xe2 x80 x89 xe2 x89 xa0 xe2 x80 x89j), which means that you need to swap pi and pj. It is guaranteed that the solution exists. In the first sample test we swap numbers on positions 3 and 4 and permutation p becomes 4 2 3 1. We pay |3 xe2 x80 x89- xe2 x80 x894| xe2 x80 x89= xe2 x80 x891 coins for that. On second turn we swap numbers on positions 1 and 3 and get permutation 3241 equal to s. We pay |3 xe2 x80 x89- xe2 x80 x891| xe2 x80 x89= xe2 x80 x892 coins for that. In total we pay three coins."...

Tutorials

Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
27585192 srijansingh E June 5, 2017, 2:50 p.m. OK GNU C TESTS 76 280 16076800 2400
20756843 Wuvin E Sept. 19, 2016, 1:42 p.m. OK GNU C++ TESTS 76 15 16076800 2400
37264744 bojverdict1 E April 13, 2018, 4:55 a.m. OK GNU C++ TESTS 76 31 5120000 2400
19060689 vjudge5 E July 13, 2016, 2:21 a.m. OK GNU C++ TESTS 76 46 8089600 2400
27327862 Ajatar E May 25, 2017, 1:51 a.m. OK GNU C++ TESTS 76 280 33075200 2400
29700356 vjudge4 E Aug. 23, 2017, 7:26 a.m. OK GNU C++ TESTS 76 295 12697600 2400
32520203 hustpanda E Nov. 21, 2017, 8:56 a.m. OK GNU C++ TESTS 76 295 15974400 2400
27319461 vjudge3 E May 24, 2017, 12:11 p.m. OK GNU C++ TESTS 76 295 23961600 2400
29702588 vjudge2 E Aug. 23, 2017, 9:11 a.m. OK GNU C++ TESTS 76 296 12595200 2400
29599197 vjudge4 E Aug. 19, 2017, 1:16 p.m. OK GNU C++ TESTS 76 296 12595200 2400
32307866 vjudge5 E Nov. 14, 2017, 9:42 a.m. OK GNU C++ TESTS 76 296 12800000 2400
34191362 doncjc E Jan. 15, 2018, 7:59 a.m. OK GNU C++11 TESTS 76 15 2252800 2400
20644972 letsbe E Sept. 15, 2016, 5:07 p.m. OK GNU C++11 TESTS 76 31 102400 2400
18659024 Qudrat_Ibadullayev E June 23, 2016, 7:42 a.m. OK GNU C++11 TESTS 76 31 204800 2400
45396616 454933608 E Nov. 7, 2018, 5:10 a.m. OK GNU C++11 TESTS 76 31 8294400 2400
58990961 Tameshk E Aug. 18, 2019, 9:12 a.m. OK GNU C++11 TESTS 76 46 102400 2400
63990865 SI_AM E Nov. 1, 2019, 1:05 p.m. OK GNU C++11 TESTS 76 46 204800 2400
36264759 Mohammadreza_mz E March 14, 2018, 4:46 a.m. OK GNU C++11 TESTS 76 46 10547200 2400
40986006 ReaLNero1 E July 30, 2018, 8:17 p.m. OK GNU C++11 TESTS 76 46 15872000 2400
54530992 PedyD E May 23, 2019, 5:03 p.m. OK GNU C++11 TESTS 76 78 512000 2400
61579719 vjudge4 E Oct. 1, 2019, 12:40 a.m. OK GNU C++11 TESTS 76 124 8192000 2400
29435620 kasrakhoshjoo E Aug. 13, 2017, 1:59 p.m. OK GNU C++14 TESTS 76 15 2252800 2400
27328763 wtltw E May 25, 2017, 3:37 a.m. OK GNU C++14 TESTS 76 15 22425600 2400
27779559 cr0n E June 14, 2017, 7:22 p.m. OK GNU C++14 TESTS 76 31 102400 2400
53609192 Salix E May 1, 2019, 12:06 p.m. OK GNU C++14 TESTS 76 31 204800 2400
48924982 rcbits16 E Jan. 25, 2019, 9:53 a.m. OK GNU C++14 TESTS 76 31 204800 2400
29597277 2020.01.09_Restart E Aug. 19, 2017, 11:52 a.m. OK GNU C++14 TESTS 76 31 204800 2400
27328784 wtltw E May 25, 2017, 3:38 a.m. OK GNU C++14 TESTS 76 31 204800 2400
36176109 ArshiaDadras E March 10, 2018, 7:05 p.m. OK GNU C++14 TESTS 76 31 2048000 2400
37285964 qdd E April 13, 2018, 1:22 p.m. OK GNU C++14 TESTS 76 31 3481600 2400
37281043 qdd E April 13, 2018, 10:48 a.m. OK GNU C++14 TESTS 76 31 3481600 2400
66907232 ruo E Dec. 15, 2019, 5:29 a.m. OK GNU C++17 TESTS 76 31 204800 2400
40748957 aki167yuuki E July 25, 2018, 4:26 p.m. OK GNU C++17 TESTS 76 31 32768000 2400
54531049 vjudge3 E May 23, 2019, 5:05 p.m. OK GNU C++17 TESTS 76 62 614400 2400
40749861 aki167yuuki E July 25, 2018, 4:59 p.m. OK GNU C++17 TESTS 76 93 409600 2400
61461724 vjudge1 E Sept. 29, 2019, 8:48 a.m. OK GNU C++17 TESTS 76 108 16281600 2400
52313085 m1sch3f E April 4, 2019, 3:40 p.m. OK GNU C++17 TESTS 76 187 25907200 2400
67271678 Temotoloraia E Dec. 20, 2019, 8:34 a.m. OK GNU C++17 TESTS 76 233 10854400 2400
52954763 AryaKnight E April 18, 2019, 1:20 p.m. OK GNU C++17 TESTS 76 233 12697600 2400
45506849 vjudge4 E Nov. 10, 2018, 11:03 a.m. OK GNU C++17 TESTS 76 234 16486400 2400
53769104 hongzhiyin E May 5, 2019, 3:22 a.m. OK GNU C++17 TESTS 76 234 24678400 2400
26744786 molikto E April 29, 2017, 9:48 a.m. OK Java 8 TESTS 76 187 21094400 2400
20946572 marcose18 E Sept. 27, 2016, 1:07 p.m. OK Java 8 TESTS 76 296 37888000 2400
61225729 Dukkha E Sept. 24, 2019, 3:10 p.m. OK Java 8 TESTS 76 374 17817600 2400
43570482 AQT E Sept. 29, 2018, 12:45 p.m. OK Java 8 TESTS 76 420 17408000 2400
68023770 Ameliorate E Jan. 1, 2020, 3:16 a.m. OK Java 8 TESTS 76 467 22937600 2400
43634277 augurar E Oct. 1, 2018, 7:37 a.m. OK Java 8 TESTS 76 467 62668800 2400
24435821 MedoN11 E Feb. 4, 2017, 4:05 p.m. OK Java 8 TESTS 76 545 45465600 2400
43740169 PrakharJain E Oct. 3, 2018, 5:33 p.m. OK Java 8 TESTS 76 623 35840000 2400
35757178 Noureldin E Feb. 27, 2018, 9:39 a.m. OK Java 8 TESTS 76 795 86016000 2400
35894821 _____k_____ E March 3, 2018, 4:30 p.m. OK PyPy 3 TESTS 76 171 23449600 2400
35894086 ______n______ E March 3, 2018, 4:13 p.m. OK PyPy 3 TESTS 76 171 23449600 2400
35893860 ______u______ E March 3, 2018, 4:08 p.m. OK PyPy 3 TESTS 76 171 23449600 2400
35893784 _____i_____ E March 3, 2018, 4:07 p.m. OK PyPy 3 TESTS 76 171 23449600 2400
35884967 ______h______ E March 3, 2018, 1:21 p.m. OK PyPy 3 TESTS 76 171 23449600 2400
35884664 ______k______ E March 3, 2018, 1:15 p.m. OK PyPy 3 TESTS 76 171 23449600 2400
35883527 ______i______ E March 3, 2018, 12:56 p.m. OK PyPy 3 TESTS 76 171 23449600 2400
35874864 ______M______ E March 3, 2018, 8:03 a.m. OK PyPy 3 TESTS 76 171 23449600 2400

remove filters

Back to search problems