Submission #2528873


Source Code Expand

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long int;

int saisyo(ll max, ll min, ll t){
    ll s = max - min;
    ll a = t;
    if(s < a){
        return s;
    }else if(a <= s){
        return a;
    }
}

int main(){
    int H, W;
    int h; //Aの高さ
    int h2; //Bの高さ
    int w; //Bの横の長さ
    ll SA, SB, SC;
    ll Smax, Smin;
    ll ans= H * W;
    cin >> H >> W;
    for(int i=1; i<H; i++){
        h = i;
        SA = h * W;
        w = W/2;
        SB = (H-h) * w;
        SC = H*W - (SA+SB);
        Smax = max({SA, SB, SC});
        Smin = min({SA, SB, SC});
        ans = saisyo(Smax, Smin, ans);

        h2 = (H-h)/2;
        SB = h2 * W;
        SC = H*W - (SA+SB);
        Smax = max({SA, SB, SC});
        Smin = min({SA, SB, SC});
        ans = saisyo(Smax, Smin, ans);
    }

    swap(H, W);
    for(int i=1; i<H; i++){
        h = i;
        SA = h * W;
        w = W/2;
        SB = (H-h) * w;
        SC = H*W - (SA+SB);
        Smax = max({SA, SB, SC});
        Smin = min({SA, SB, SC});
        ans = saisyo(Smax, Smin, ans);

        h2 = (H-h)/2;
        SB = h2 * W;
        SC = H*W - (SA+SB);
        Smax = max({SA, SB, SC});
        Smin = min({SA, SB, SC});
        ans = saisyo(Smax, Smin, ans);
    }
    
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task C - Chocolate Bar
User iyo1470
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1520 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 × 1
WA × 4
AC × 7
WA × 13
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 WA 1 ms 256 KB
0_02.txt WA 1 ms 256 KB
0_03.txt WA 2 ms 256 KB
0_04.txt WA 2 ms 256 KB
1_00.txt WA 1 ms 256 KB
1_01.txt WA 2 ms 256 KB
1_02.txt AC 2 ms 256 KB
1_03.txt AC 2 ms 256 KB
1_04.txt WA 2 ms 256 KB
1_05.txt WA 2 ms 256 KB
1_06.txt AC 2 ms 256 KB
1_07.txt AC 2 ms 256 KB
1_08.txt WA 2 ms 256 KB
1_09.txt WA 2 ms 256 KB
1_10.txt WA 2 ms 256 KB
1_11.txt AC 2 ms 256 KB
1_12.txt AC 2 ms 256 KB
1_13.txt WA 2 ms 256 KB
1_14.txt WA 1 ms 256 KB