Submission #11379651


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

long long solve(long long x, long long y) {
  long long res = 1e18;
  for (int i = 1; i < x; ++i) {
    long long a = (x-i)*y;
    long long b = i*(y/2);
    long long c = i*(y-y/2);
    long long mx = max(a, max(b, c));
    long long mn = min(a, min(b, c));
    if (mx - mn < res) res = mx-mn;
  }
  return res;
}

long long solve2(long long x, long long y) {
  long long a = (x/3)*y;
  long long b = (x-2*(x/3))*y;
  return abs(a-b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int h, w;
  cin >> h >> w;

  
  long long a = min(solve(h, w), solve(w, h)); 
  long long b = min(solve2(h, w), solve2(w, h)); 

  cout << min(a, b) << endl;

  return 0;
}

Submission Info

Submission Time
Task C - Chocolate Bar
User whatsinitforme
Language C++14 (GCC 5.4.1)
Score 0
Code Size 762 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 × 5
AC × 18
WA × 2
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 WA 1 ms 256 KB
1_05.txt AC 2 ms 256 KB
1_06.txt AC 2 ms 256 KB
1_07.txt AC 1 ms 256 KB
1_08.txt AC 2 ms 256 KB
1_09.txt WA 2 ms 256 KB
1_10.txt AC 2 ms 256 KB
1_11.txt AC 1 ms 256 KB
1_12.txt AC 2 ms 256 KB
1_13.txt AC 1 ms 256 KB
1_14.txt AC 1 ms 256 KB