Submission #19680247


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD int(1e9+7)
#define INF int(1e9+7)
#define LINF ll(1e18+7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<ll,ll>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int a,b;
int l[1100];
int r[1100];
int dp1[1100][1100];
int dp2[1100][1100];

int main(){
  cin>>a>>b;
  rep(i,a) cin>>l[i];
  rep(i,b) cin>>r[i];
  rep(i,a+1)rep(j,b+1) dp2[i][j]=INF;
  dp1[0][0]=0;
  dp2[0][0]=0;
  rep(i,a+1)rep(j,b+1){
    if(i-1>=0) chmin(dp2[i][j],dp1[i-1][j]);
    if(j-1>=0) chmin(dp2[i][j],dp1[i][j-1]);
    if(i-1>=0) chmax(dp1[i][j],dp2[i-1][j]+l[a-i]);
    if(j-1>=0) chmax(dp1[i][j],dp2[i][j-1]+r[b-j]);
  }
  cout<<dp1[a][b]<<endl;
}

Submission Info

Submission Time
Task B - ゲーム
User uytvcc
Language C++ (GCC 9.2.1)
Score 3
Code Size 776 Byte
Status AC
Exec Time 16 ms
Memory 12120 KB

Judge Result

Set Name All
Score / Max Score 3 / 3
Status
AC × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 AC 8 ms 3628 KB
01 AC 14 ms 10404 KB
02 AC 16 ms 12120 KB
90 AC 4 ms 3372 KB
91 AC 2 ms 3532 KB