Submission #5913649
Source Code Expand
#include "bits/stdc++.h" using namespace std; #define ll long long int #define rep(i,n) for( int i = 0; i < n; i++ ) #define rrep(i,n) for( int i = n; i >= 0; i-- ) #define REP(i,s,t) for( int i = s; i <= t; i++ ) #define RREP(i,s,t) for( int i = s; i >= t; i-- ) #define dump(x) cerr << #x << " = " << (x) << endl; #define INF 2000000000 #define mod 1000000007 #define INF2 1000000000000000000 #define int long long signed main(void) { cin.tie(0); ios::sync_with_stdio(false); int H, W; cin >> H >> W; if (H % 3 == 0 || W % 3 == 0) { cout << 0 << endl; return 0; } int ans = min(H, W); rep(k, 2) { for(int i = max(0LL, H / 3 - 1000); i <= min(H, H / 3 + 1000); i++) { for(int j = 0; j <= W; j++) { int S1 = W * i; int S2 = j * (H - i); int S3 = (W - j) * (H - i); ans = min(ans, max({S1, S2, S3}) - min({S1, S2, S3})); } } swap(H, W); } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Chocolate Bar |
User | toame |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1085 Byte |
Status | AC |
Exec Time | 877 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 | 2 ms | 256 KB |
0_04.txt | AC | 877 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 2 ms | 256 KB |
1_02.txt | AC | 1 ms | 256 KB |
1_03.txt | AC | 1 ms | 256 KB |
1_04.txt | AC | 265 ms | 256 KB |
1_05.txt | AC | 508 ms | 256 KB |
1_06.txt | AC | 1 ms | 256 KB |
1_07.txt | AC | 1 ms | 256 KB |
1_08.txt | AC | 454 ms | 256 KB |
1_09.txt | AC | 537 ms | 256 KB |
1_10.txt | AC | 714 ms | 256 KB |
1_11.txt | AC | 1 ms | 256 KB |
1_12.txt | AC | 1 ms | 256 KB |
1_13.txt | AC | 440 ms | 256 KB |
1_14.txt | AC | 245 ms | 256 KB |