Submission #2105568


Source Code Expand

#include <bits/stdc++.h>
#define MAX_OBJECT 1005
#define MAX_POINT 1005

using namespace std;

int a_max = 0;
int b_max = 0;
int a_side[MAX_OBJECT] = {0};
int b_side[MAX_OBJECT] = {0};
int dp[2][MAX_OBJECT][MAX_OBJECT] = {{{0}}};
//true = すめけ君   false = すぬけ君

//playerがtrueのとき「すめけ君」の利益を最大にする値を選ぶ playerがfalseのとき「すめけ君」の利益を最小にする値を選ぶ
int rec(bool player = true, int a = 0, int b = 0){
    
    int &res = dp[player][a][b];
    if(~res){
        return res;
    }
    
    int s = (player) ? a_side[a] : 0;
    int r = (player) ? b_side[b] : 0;
    int x, y;
    if(a < a_max && b < b_max){
        if(player){
            res = ((x = rec(!player, a + 1, b)) > (y = rec(!player, a, b + 1))) ? (x + s) : (y + r);
        }
        else{
            res = ((x = rec(!player, a + 1, b)) > (y = rec(!player, a, b + 1))) ? (y + s) : (x + r);
        }
    }
    else if(a < a_max){
        res = rec(!player, a + 1, b) + s;
    }
    else if(b < b_max){
        res = rec(!player, a, b + 1) + r;
    }
    else{
        return 0;
    }
    
    return res;
}

int main(void){
    
    scanf("%d", &a_max);
    scanf("%d", &b_max);
    
    int i;
    for(i = 0; i < a_max; ++i){
        scanf("%d", &a_side[i]);
    }
    for(i = 0; i < b_max; ++i){
        scanf("%d", &b_side[i]);
    }
    
    memset(dp, -1, sizeof(dp));
    
    printf("%d\n", rec());
    
    return 0;
}

Submission Info

Submission Time
Task B - ゲーム
User sgneet
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1542 Byte
Status WA
Exec Time 14 ms
Memory 8320 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:48:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &a_max);
                        ^
./Main.cpp:49:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &b_max);
                        ^
./Main.cpp:53:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a_side[i]);
                                ^
./Main.cpp:56:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &b_side[i]);
                                ^

Judge Result

Set Name All
Score / Max Score 0 / 3
Status
AC × 2
WA × 3
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 WA 4 ms 8192 KB
01 WA 11 ms 8320 KB
02 WA 14 ms 8320 KB
90 AC 4 ms 8192 KB
91 AC 4 ms 8192 KB