Submission #19675436


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];
  dp1[a][b]=0;
  dp2[a][b]=0;
  for(int i=a; i>=0; i--)for(int j=b; j>=0; j--){
    if((i+j)%2==(a+b)%2){
      if(i-1>=0) chmax(dp1[i-1][j],dp1[i][j]+l[a-i]);
      if(j-1>=0) chmax(dp1[i][j-1],dp1[i][j]+r[b-j]);
      if(i-1>=0) dp2[i-1][j]=dp2[i][j];
      if(j-1>=0) dp2[i][j-1]=dp2[i][j];
    }else{
      if(i-1>=0) chmax(dp2[i-1][j],dp2[i][j]+l[a-i]);
      if(j-1>=0) chmax(dp2[i][j-1],dp2[i][j]+r[b-j]);
      if(i-1>=0) dp1[i-1][j]=dp1[i][j];
      if(j-1>=0) dp1[i][j-1]=dp1[i][j];
    }
  }
  cout<<dp1[0][0]<<endl;
}

Submission Info

Submission Time
Task B - ゲーム
User uytvcc
Language C++ (GCC 9.2.1)
Score 0
Code Size 995 Byte
Status WA
Exec Time 19 ms
Memory 12100 KB

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 8 ms 3516 KB
01 WA 16 ms 10232 KB
02 WA 19 ms 12100 KB
90 AC 4 ms 3568 KB
91 AC 2 ms 3540 KB