Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #1762871

Source Code Expand

Copy
```#include <iostream>
using namespace std;
int A[2000];
int N;
int memo[2000][2];
int score(int player, int i, int card1, int card2){
if(memo[i][player] > 0) return memo[i][player];
if(player){//X の番　最大化したい
int ret = abs(A[N-1]-card2);
for(int j = i; j < N-1; ++j){
ret = max(ret, score(0,j+1,A[j],card2));
}
memo[i][player] = ret;
return ret;
}else{//最小化
int ret = abs(A[N-1]-card1);
for(int j = i; j < N-1; ++j){
ret = min(ret, score(1,j+1,A[j],card1));
}
memo[i][player] = ret;
return ret;
}
}

int main(){
int Z, W;
cin >> N >> Z >> W;
for(int i = 0; i < N; ++i) cin >> A[i];
for(int i = 0; i < N; ++i) for(int j = 0; j < 2; ++j) memo[i][j] = -1;
cout << score(1,0,Z,W) << endl;
return 0;
}
```

#### Submission Info

Submission Time 2017-11-11 21:57:27+0900 D - ABS TAB C++14 (GCC 5.4.1) 0 821 Byte WA 15 ms 384 KB

#### Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 example_0, example_1, example_2, example_3
All 0 / 500 example_0, example_1, example_2, example_3, one_0, one_1, one_2, one_3, one_4, one_5, one_6, one_7, rand_0, rand_1, rand_10, rand_11, rand_12, rand_13, rand_14, rand_15, rand_2, rand_3, rand_4, rand_5, rand_6, rand_7, rand_8, rand_9
Case Name Status Exec Time Memory
example_0 1 ms 256 KB
example_1 1 ms 256 KB
example_2 1 ms 256 KB
example_3 1 ms 256 KB
one_0 1 ms 256 KB
one_1 1 ms 256 KB
one_2 1 ms 256 KB
one_3 1 ms 256 KB
one_4 1 ms 256 KB
one_5 1 ms 256 KB
one_6 1 ms 256 KB
one_7 1 ms 256 KB
rand_0 15 ms 384 KB
rand_1 3 ms 256 KB
rand_10 15 ms 384 KB
rand_11 4 ms 256 KB
rand_12 15 ms 384 KB
rand_13 11 ms 384 KB
rand_14 15 ms 384 KB
rand_15 1 ms 256 KB
rand_2 15 ms 384 KB
rand_3 11 ms 384 KB
rand_4 15 ms 384 KB
rand_5 6 ms 256 KB
rand_6 15 ms 384 KB
rand_7 7 ms 256 KB
rand_8 15 ms 384 KB
rand_9 12 ms 384 KB