Submission #1295788
Source Code Expand
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } //--------------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------------- ∧_∧ ∧_∧ (´<_` ) Welcome to My Coding Space! ( ´_ゝ`) / ⌒i / \ | | / / ̄ ̄ ̄ ̄/ | __(__ニつ/ _/ .| .|____ \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ typedef long long ll; #define INF 1LL << 60 ll H, W; //--------------------------------------------------------------------------------------------------- ll f(ll a, ll b, ll c) { ll ma = max(a, max(b, c)); ll mi = min(a, min(b, c)); return ma - mi; } //--------------------------------------------------------------------------------------------------- ll solA() { ll res = INF; if (2 < H) { ll h = H / 3; if (H % 3 == 0) return 0; res = min(res, W); } if (2 < W) { ll w = W / 3; if (W % 3 == 0) return 0; res = min(res, H); } return res; } //--------------------------------------------------------------------------------------------------- ll solB() { ll res = INF; rep(x, 1, W) { ll xx = x; ll b = H / 2; res = min(res, f(xx * b, xx * (H - b), (W - xx) * H)); } rep(y, 1, H) { ll yy = y; ll b = W / 2; res = min(res, f(yy * b, yy * (W - b), (H - yy) * W)); } return res; } //--------------------------------------------------------------------------------------------------- void _main() { cin >> H >> W; ll ans = min(solA(), solB()); cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Chocolate Bar |
User | hamayanhamayan |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 2132 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
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 | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
0_03.txt | AC | 1 ms | 256 KB |
0_04.txt | AC | 2 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 1 ms | 256 KB |
1_02.txt | AC | 1 ms | 256 KB |
1_03.txt | AC | 1 ms | 256 KB |
1_04.txt | AC | 1 ms | 256 KB |
1_05.txt | AC | 1 ms | 256 KB |
1_06.txt | AC | 2 ms | 256 KB |
1_07.txt | AC | 1 ms | 256 KB |
1_08.txt | AC | 1 ms | 256 KB |
1_09.txt | AC | 1 ms | 256 KB |
1_10.txt | AC | 2 ms | 256 KB |
1_11.txt | AC | 1 ms | 256 KB |
1_12.txt | AC | 1 ms | 256 KB |
1_13.txt | AC | 1 ms | 256 KB |
1_14.txt | AC | 1 ms | 256 KB |