Submission #2548670


Source Code Expand

#include <iostream>
using namespace std;
int a, b, p[1000], q[1000];
int game(int x, int y) {
    if (x == a && y == b) {
        return 0;
    } else if (x == a) {
        return game(x, y + 1) + ((x + y) % 2 == 0 ? q[y] : 0);
    } else if (y == b) {
        return game(x + 1, y) + ((x + y) % 2 == 0 ? p[x] : 0);
    } else if ((x + y) % 2 == 0) {
        return max(game(x + 1, y) + p[x], game(x, y + 1) + q[y]);
    } else {
        return min(game(x + 1, y), game(x, y + 1));
    }
}

int main(void){
    // Your code here!
    cin >> a >> b;
    for (int i = 0; i < a; i++) cin >> p[i];
    for (int i = 0; i < b; i++) cin >> q[i];
    cout << game(0, 0) << endl;
}

Submission Info

Submission Time
Task B - ゲーム
User kwfumou1242
Language C++14 (GCC 5.4.1)
Score 0
Code Size 697 Byte
Status TLE
Exec Time 2103 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 0 / 3
Status
AC × 3
TLE × 2
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 AC 3 ms 256 KB
01 TLE 2103 ms 256 KB
02 TLE 2103 ms 256 KB
90 AC 1 ms 256 KB
91 AC 1 ms 256 KB