Submission #19680244


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[0][1]<<" "<<dp2[0][1]<<endl;
  cout<<dp1[0][2]<<" "<<dp2[0][2]<<endl;
  cout<<dp1[a][b]<<endl;
}

Submission Info

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

Judge Result

Set Name All
Score / Max Score 0 / 3
Status
WA × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 WA 10 ms 3668 KB
01 WA 12 ms 10428 KB
02 WA 18 ms 12184 KB
90 WA 3 ms 3440 KB
91 WA 2 ms 3468 KB