Submission #97708


Source Code Expand

Copy
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int list_a[1000];
int list_b[1000];
int dp[1000][1000];

int a, b, sum = 0, answer;

void solver(int a_c, int b_c, int value){
  if(a_c == 0 && b_c == 0){
    if(dp[a_c][b_c] > abs(value-(sum-value))){
      answer = value;
      dp[a_c][b_c] = abs(value-(sum-value));
    }
  }

  if(a_c != 0 && b_c != 0){
    solver(max(a_c-2,0), b_c, value + list_a[a - a_c]);
    solver(a_c, max(b_c-2,0), value + list_b[b - b_c]);
    solver(a_c-1, b_c-1, value + list_a[a - a_c]);
    solver(a_c-1, b_c-1, value + list_b[b - b_c]);
  }else if(a_c != 0){
    solver(max(a_c-2,0), b_c, value + list_a[a - a_c]);
  }else if(b_c != 0){
    solver(a_c, max(b_c-2,0), value + list_b[b - b_c]);
  }
}

int main(){
  memset(list_a, 0, sizeof(list_a));
  memset(list_b, 0, sizeof(list_b));
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 10000000;
  int odd_a = 0, even_a = 0;
  int odd_b = 0, even_b = 0;

  cin >> a >> b;

  for(int i = 0; i < a; i++){
    cin >> list_a[i];
    sum += list_a[i];

    if(i % 2 == 0){
      odd_a += list_a[i];
    }else{
      even_a += list_a[i];
    }
  }

  for(int i = 0; i < b; i++){
    cin >> list_b[i];
    sum += list_b[i];
    if(i % 2 == 0){
      odd_b += list_b[i];
    }else{
      even_b += list_b[i];
    }
  }

  //solver(a, b, 0);
  int max_value = 0;
  max_value = max(max_value, odd_a + odd_b);
  max_value = max(max_value, odd_a + even_b);
  max_value = max(max_value, even_a + odd_b);
  max_value = max(max_value, even_a + even_b);
  cout << max_value << endl;
  return 0;
}

Submission Info

Submission Time
Task B - ゲーム
User siman
Language C++ (G++ 4.6.4)
Score 0
Code Size 1660 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:34:35: error: ‘memset’ was not declared in this scope