Submission #1295821


Source Code Expand

def scan; gets.split.map(&:to_i); end

hh,ww = scan

min = hh*ww
1.upto(ww-1){|x|
    a = x*hh
    b = (ww-x)*(hh/2)
    c = (ww-x)*((hh+1)/2)
    min = [[a,b,c].max-[a,b,c].min,min].min
}
1.upto(hh-1){|y|
    a = y*ww
    b = (hh-y)*(ww/2)
    c = (hh-y)*((ww+1)/2)
    min = [[a,b,c].max-[a,b,c].min,min].min
}
a = (hh/3)*ww
b = ((hh+1)/3)*ww
c = ((hh+2)/3)*ww
min = [[a,b,c].max-[a,b,c].min,min].min
a = (ww/3)*hh
b = ((ww+1)/3)*hh
c = ((ww+2)/3)*hh
min = [[a,b,c].max-[a,b,c].min,min].min

p min

Submission Info

Submission Time
Task C - Chocolate Bar
User m_buyoh
Language Ruby (2.3.3)
Score 400
Code Size 525 Byte
Status AC
Exec Time 254 ms
Memory 1788 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 5
AC × 20
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt
Case Name Status Exec Time Memory
0_00.txt AC 7 ms 1788 KB
0_01.txt AC 7 ms 1788 KB
0_02.txt AC 7 ms 1788 KB
0_03.txt AC 133 ms 1788 KB
0_04.txt AC 254 ms 1788 KB
1_00.txt AC 7 ms 1788 KB
1_01.txt AC 129 ms 1788 KB
1_02.txt AC 99 ms 1788 KB
1_03.txt AC 126 ms 1788 KB
1_04.txt AC 81 ms 1788 KB
1_05.txt AC 151 ms 1788 KB
1_06.txt AC 223 ms 1788 KB
1_07.txt AC 127 ms 1788 KB
1_08.txt AC 135 ms 1788 KB
1_09.txt AC 160 ms 1788 KB
1_10.txt AC 204 ms 1788 KB
1_11.txt AC 89 ms 1788 KB
1_12.txt AC 186 ms 1788 KB
1_13.txt AC 129 ms 1788 KB
1_14.txt AC 75 ms 1788 KB