Submission #97406
Source Code Expand
#include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <typeinfo> #include <queue> using namespace std; typedef long long ll; int a, b; int ad[1003], bd[1003]; int dp[1003][1003]; int calc(int x, int y) { if (dp[x][y] != -1) return dp[x][y]; if (x > a || y > b) return -1; if (x == a && y == b) return 0; int r = 1e8; if ((x+y)%2) { if (x < a) { r = calc(x+1, y); } if (y < b) { r = min(r, calc(x, y+1)); } dp[x][y] = r; return r; } else { r = 0; if (x < a) { r = calc(x+1, y) + ad[x]; } if (y < b) { r = max(r, calc(x, y+1) + bd[y]); } dp[x][y] = r; return r; } } int main() { cin >> a >> b; for (int i = 0; i < a; i++) { cin >> ad[i]; } for (int i = 0; i < b; i++) { cin >> bd[i]; } fill((int *)dp, (int *)dp+1003*1003, -1); cout << calc(0, 0) << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - ゲーム |
User | yosupo |
Language | C++11 (GCC 4.8.1) |
Score | 3 |
Code Size | 1000 Byte |
Status | AC |
Exec Time | 44 ms |
Memory | 4772 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 3 / 3 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00, 01, 02, 90, 91 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00 | AC | 27 ms | 4744 KB |
01 | AC | 39 ms | 4640 KB |
02 | AC | 44 ms | 4748 KB |
90 | AC | 26 ms | 4540 KB |
91 | AC | 26 ms | 4772 KB |