Submission #6416428


Source Code Expand

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int H, W;
  cin >> H >> W;

  int ans = INF;
  for (int i = 1; i < H; i++)
  {
    int S0 = i * W;
    int S1 = (H - i) * (W / 2);
    int S2 = H * W - S0 - S1;
    chmin(ans, max({S0, S1, S2}) - min({S0, S1, S2}));
  }
  swap(H, W);
  for (int i = 1; i < H; i++)
  {
    int S0 = i * W;
    int S1 = (H - i) * (W / 2);
    int S2 = H * W - S0 - S1;
    chmin(ans, max({S0, S1, S2}) - min({S0, S1, S2}));
  }

  cout << ans << endl;
}

Submission Info

Submission Time
Task C - Chocolate Bar
User miscalculation53
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1121 Byte
Status WA
Exec Time 2 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 4
WA × 1
AC × 15
WA × 5
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 WA 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 WA 1 ms 256 KB
1_04.txt WA 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 WA 1 ms 256 KB
1_10.txt AC 2 ms 256 KB
1_11.txt AC 1 ms 256 KB
1_12.txt WA 1 ms 256 KB
1_13.txt AC 1 ms 256 KB
1_14.txt AC 1 ms 256 KB