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.
Problems
B"Jeff loves regular bracket sequences. Today Jeff is going to take a piece of paper and write out the regular bracket sequence, consisting of nm brackets. Let's number all brackets of this sequence from 0 to nm - 1 from left to right. Jeff knows that he is going to spend ai mod n liters of ink on the i-th bracket of the sequence if he paints it opened and bi mod n liters if he paints it closed. You've got sequences a, b and numbers n, m. What minimum amount of ink will Jeff need to paint a regular bracket sequence of length nm? Operation x mod y means taking the remainder after dividing number x by number y. The first line contains two integers n and m (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x8920; 1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89m xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89107; m is even). The next line contains n integers: a0, a1, ..., an xe2 x80 x89- xe2 x80 x891 (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ai xe2 x80 x89 xe2 x89 xa4 xe2 x80 x8910). The next line contains n integers: b0, b1, ..., bn xe2 x80 x89- xe2 x80 x891 (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89bi xe2 x80 x89 xe2 x89 xa4 xe2 x80 x8910). The numbers are separated by spaces. In a single line print the answer to the problem -- the minimum required amount of ink in liters. In the first test the optimal sequence is: ()()()()()(), the required number of ink liters is 12."... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
5641139 |
zhzq123 |
C |
Jan. 9, 2014, 5:39 a.m. |
OK |
FPC |
TESTS |
28 |
30 |
204800 |
|
2800 |
4809859 |
Nik_Storm_2010 |
C |
Oct. 16, 2013, 7:21 p.m. |
OK |
FPC |
TESTS |
28 |
30 |
1638400 |
|
2800 |
5641110 |
zhzq123 |
C |
Jan. 9, 2014, 5:27 a.m. |
OK |
FPC |
TESTS |
28 |
30 |
4198400 |
|
2800 |
5641109 |
zhzq123 |
C |
Jan. 9, 2014, 5:25 a.m. |
OK |
FPC |
TESTS |
28 |
30 |
4198400 |
|
2800 |
31882158 |
MOBrocks |
C |
Oct. 30, 2017, 6 a.m. |
OK |
GNU C |
TESTS |
28 |
30 |
0 |
|
2800 |
4919322 |
vfleaking |
C |
Oct. 28, 2013, 12:19 p.m. |
OK |
GNU C++ |
TESTS |
28 |
15 |
0 |
|
2800 |
21954416 |
nitvjudge2 |
C |
Nov. 1, 2016, 2:03 a.m. |
OK |
GNU C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
21954370 |
nitvjudge1 |
C |
Nov. 1, 2016, 2 a.m. |
OK |
GNU C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
21863424 |
vjudge2 |
C |
Oct. 29, 2016, 4:39 a.m. |
OK |
GNU C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
15551020 |
vjudge1 |
C |
Jan. 24, 2016, 8:51 a.m. |
OK |
GNU C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
15551011 |
hnuRoshan |
C |
Jan. 24, 2016, 8:50 a.m. |
OK |
GNU C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
14040465 |
130705009 |
C |
Nov. 3, 2015, 11:07 a.m. |
OK |
GNU C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
12315252 |
-XraY- |
C |
Aug. 2, 2015, 1:14 p.m. |
OK |
GNU C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
11573328 |
KarimElSheikh |
C |
June 13, 2015, 7:43 p.m. |
OK |
GNU C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
11328610 |
vjudge5 |
C |
May 28, 2015, 5:28 a.m. |
OK |
GNU C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
9867805 |
zhabo |
C |
Feb. 16, 2015, 8:42 a.m. |
OK |
GNU C++0x |
TESTS |
28 |
30 |
0 |
|
2800 |
9867803 |
zhabo |
C |
Feb. 16, 2015, 8:41 a.m. |
OK |
GNU C++0x |
TESTS |
28 |
30 |
0 |
|
2800 |
9867595 |
Illidan |
C |
Feb. 16, 2015, 8:18 a.m. |
OK |
GNU C++0x |
TESTS |
28 |
30 |
0 |
|
2800 |
7794794 |
wanbo |
C |
Sept. 14, 2014, 2 p.m. |
OK |
GNU C++0x |
TESTS |
28 |
30 |
0 |
|
2800 |
4985083 |
Archon.JK |
C |
Nov. 4, 2013, 10:51 a.m. |
OK |
GNU C++0x |
TESTS |
28 |
30 |
0 |
|
2800 |
4984994 |
Archon.JK |
C |
Nov. 4, 2013, 10:39 a.m. |
OK |
GNU C++0x |
TESTS |
28 |
30 |
0 |
|
2800 |
4790811 |
cylixstar |
C |
Oct. 15, 2013, 12:17 p.m. |
OK |
GNU C++0x |
TESTS |
28 |
30 |
0 |
|
2800 |
4680531 |
Feu |
C |
Oct. 5, 2013, 12:08 p.m. |
OK |
GNU C++0x |
TESTS |
28 |
30 |
102400 |
|
2800 |
4666789 |
FAU.COACH |
C |
Oct. 4, 2013, 4:35 p.m. |
OK |
GNU C++0x |
TESTS |
28 |
30 |
102400 |
|
2800 |
7571795 |
zshi |
C |
Aug. 25, 2014, 9:21 a.m. |
OK |
GNU C++0x |
TESTS |
28 |
30 |
307200 |
|
2800 |
21954421 |
787930982 |
C |
Nov. 1, 2016, 2:04 a.m. |
OK |
GNU C++11 |
TESTS |
28 |
30 |
0 |
|
2800 |
16290079 |
ppetter1025 |
C |
Feb. 23, 2016, 9:52 a.m. |
OK |
GNU C++11 |
TESTS |
28 |
30 |
0 |
|
2800 |
14028493 |
climpet |
C |
Nov. 2, 2015, 2:13 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
30 |
0 |
|
2800 |
20377593 |
xiqiao |
C |
Sept. 4, 2016, 8:21 a.m. |
OK |
GNU C++11 |
TESTS |
28 |
30 |
102400 |
|
2800 |
19492300 |
mindbeats |
C |
July 29, 2016, 4:03 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
30 |
102400 |
|
2800 |
14029814 |
climpet |
C |
Nov. 2, 2015, 3:34 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
30 |
102400 |
|
2800 |
12035308 |
Quang |
C |
July 14, 2015, 2:28 a.m. |
OK |
GNU C++11 |
TESTS |
28 |
30 |
102400 |
|
2800 |
16311847 |
tun |
C |
Feb. 24, 2016, 3:48 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
30 |
409600 |
|
2800 |
22722069 |
Y_UME |
C |
Dec. 6, 2016, 3:18 a.m. |
OK |
GNU C++11 |
TESTS |
28 |
30 |
512000 |
|
2800 |
18248289 |
yao11617 |
C |
June 4, 2016, 7:45 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
30 |
2048000 |
|
2800 |
34607942 |
The_Unbeatable |
C |
Jan. 27, 2018, 2:05 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
30 |
1945600 |
|
2800 |
47286852 |
anis028 |
C |
Dec. 20, 2018, 6:45 a.m. |
OK |
GNU C++14 |
TESTS |
28 |
60 |
0 |
|
2800 |
29580529 |
Updown |
C |
Aug. 18, 2017, 5:16 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
60 |
102400 |
|
2800 |
45339431 |
NiceBaseballCoder |
C |
Nov. 5, 2018, 7:39 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
60 |
819200 |
|
2800 |
32986159 |
jtnydv25 |
C |
Dec. 6, 2017, 7:49 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
60 |
2662400 |
|
2800 |
47291338 |
anis028 |
C |
Dec. 20, 2018, 9:26 a.m. |
OK |
GNU C++14 |
TESTS |
28 |
62 |
0 |
|
2800 |
43558735 |
iaojnh |
C |
Sept. 29, 2018, 7:44 a.m. |
OK |
GNU C++14 |
TESTS |
28 |
62 |
0 |
|
2800 |
59929985 |
Origenes |
C |
Sept. 3, 2019, 6:37 a.m. |
OK |
GNU C++14 |
TESTS |
28 |
62 |
204800 |
|
2800 |
43433608 |
racsosabe |
C |
Sept. 26, 2018, 3:33 a.m. |
OK |
GNU C++14 |
TESTS |
28 |
62 |
204800 |
|
2800 |
43427344 |
racsosabe |
C |
Sept. 25, 2018, 9:19 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
62 |
204800 |
|
2800 |
49770205 |
ONE_DAY_I_WILL |
C |
Feb. 11, 2019, 1:21 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
60 |
819200 |
|
2800 |
63372312 |
ivan100sic |
C |
Oct. 25, 2019, 9:49 a.m. |
OK |
GNU C++17 |
TESTS |
28 |
60 |
1945600 |
|
2800 |
66994959 |
how_to_become_purple |
C |
Dec. 16, 2019, 12:11 a.m. |
OK |
GNU C++17 |
TESTS |
28 |
62 |
204800 |
|
2800 |
66730999 |
-is-this-fft- |
C |
Dec. 12, 2019, 5:31 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
92 |
204800 |
|
2800 |
66828444 |
hjk1030 |
C |
Dec. 14, 2019, 9:44 a.m. |
OK |
GNU C++17 |
TESTS |
28 |
92 |
307200 |
|
2800 |
55331445 |
ruo |
C |
June 9, 2019, 11:14 a.m. |
OK |
GNU C++17 |
TESTS |
28 |
92 |
716800 |
|
2800 |
49769633 |
ONE_DAY_I_WILL |
C |
Feb. 11, 2019, 1:07 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
218 |
819200 |
|
2800 |
59543157 |
RedNextCentury |
C |
Aug. 26, 2019, 7:56 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
312 |
307200 |
|
2800 |
58204575 |
89264270823 |
C |
Aug. 3, 2019, 6:22 a.m. |
OK |
GNU C++17 |
TESTS |
28 |
374 |
512000 |
|
2800 |
4810978 |
hiukim |
C |
Oct. 17, 2013, 2:08 a.m. |
OK |
Java 6 |
TESTS |
28 |
156 |
0 |
|
2800 |
4711854 |
paul.miner |
C |
Oct. 8, 2013, 9:30 p.m. |
OK |
Java 6 |
TESTS |
28 |
218 |
0 |
|
2800 |
4686152 |
kurobaka |
C |
Oct. 6, 2013, 9:29 a.m. |
OK |
Java 7 |
TESTS |
28 |
124 |
0 |
|
2800 |
4661974 |
Petr |
C |
Oct. 4, 2013, 3:56 p.m. |
OK |
Java 7 |
TESTS |
28 |
156 |
0 |
|
2800 |
4715248 |
Footman |
C |
Oct. 9, 2013, 11:44 a.m. |
OK |
Java 7 |
TESTS |
28 |
186 |
0 |
|
2800 |
4674094 |
Egor |
C |
Oct. 4, 2013, 6:47 p.m. |
OK |
Java 7 |
TESTS |
28 |
186 |
0 |
|
2800 |
5627728 |
xenoslash |
C |
Jan. 6, 2014, 2:17 p.m. |
OK |
Java 7 |
TESTS |
28 |
186 |
204800 |
|
2800 |
4668391 |
ilyakor |
C |
Oct. 4, 2013, 4:51 p.m. |
OK |
Java 7 |
TESTS |
28 |
218 |
0 |
|
2800 |
4760561 |
mostafa_fahim |
C |
Oct. 12, 2013, 5:29 p.m. |
OK |
Java 7 |
TESTS |
28 |
372 |
0 |
|
2800 |
4671514 |
mrNobody |
C |
Oct. 4, 2013, 5:25 p.m. |
OK |
Java 7 |
TESTS |
28 |
374 |
0 |
|
2800 |
4665074 |
FattyPenguin |
C |
Oct. 4, 2013, 4:20 p.m. |
OK |
Java 7 |
TESTS |
28 |
374 |
0 |
|
2800 |
4670276 |
vyxaryx |
C |
Oct. 4, 2013, 5:11 p.m. |
OK |
Java 7 |
TESTS |
28 |
624 |
102400 |
|
2800 |
11129009 |
AlexFetisov |
C |
May 17, 2015, 6:12 p.m. |
OK |
Java 8 |
TESTS |
28 |
218 |
0 |
|
2800 |
9481475 |
Aidos |
C |
Jan. 20, 2015, 4:40 a.m. |
OK |
Java 8 |
TESTS |
28 |
280 |
0 |
|
2800 |
5808855 |
EmK |
C |
Jan. 25, 2014, 8:09 p.m. |
OK |
MS C# |
TESTS |
28 |
122 |
2764800 |
|
2800 |
5808758 |
EmK |
C |
Jan. 25, 2014, 7:51 p.m. |
OK |
MS C# |
TESTS |
28 |
124 |
2867200 |
|
2800 |
6162137 |
Scorpy |
C |
March 27, 2014, 2:29 p.m. |
OK |
MS C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
4669930 |
xh286286 |
C |
Oct. 4, 2013, 5:08 p.m. |
OK |
MS C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
4669853 |
kriii |
C |
Oct. 4, 2013, 5:07 p.m. |
OK |
MS C++ |
TESTS |
28 |
30 |
0 |
|
2800 |
4708533 |
tomas.svab |
C |
Oct. 8, 2013, 1:02 p.m. |
OK |
MS C++ |
TESTS |
28 |
30 |
307200 |
|
2800 |
5695336 |
Wasted |
C |
Jan. 15, 2014, 10:38 a.m. |
OK |
MS C++ |
TESTS |
28 |
30 |
4300800 |
|
2800 |
8750708 |
felfer |
C |
Nov. 18, 2014, 9:48 p.m. |
OK |
MS C++ |
TESTS |
28 |
62 |
0 |
|
2800 |
10849610 |
polequoll |
C |
April 24, 2015, 4:19 p.m. |
OK |
MS C++ |
TESTS |
28 |
62 |
40550400 |
|
2800 |
10849787 |
polequoll |
C |
April 24, 2015, 4:36 p.m. |
OK |
MS C++ |
TESTS |
28 |
92 |
45363200 |
|
2800 |
5118473 |
NSU_Trains |
C |
Nov. 15, 2013, 3:25 p.m. |
OK |
MS C++ |
TESTS |
28 |
186 |
1843200 |
|
2800 |
4664818 |
stgatilov |
C |
Oct. 4, 2013, 4:17 p.m. |
OK |
MS C++ |
TESTS |
28 |
186 |
1843200 |
|
2800 |
15144046 |
HappyNewYearMike |
C |
Jan. 1, 2016, 12:04 a.m. |
OK |
Scala |
TESTS |
28 |
560 |
204800 |
|
2800 |
4834523 |
limed |
C |
Oct. 20, 2013, 4:26 p.m. |
OK |
Scala |
TESTS |
28 |
592 |
0 |
|
2800 |
remove filters
Back to search problems