Submission #35889610


Source Code Expand

#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int N, x, y;
  cin >> N >> x >> y;
  N--;
  {
    int A1;
    cin >> A1;
    x -= A1;
  }
  int Nx = N / 2, Ny = (N + 1) / 2;
  vector<int> Ax(Nx), Ay(Ny);
  for (int i = 0; i < N; i++)
  {
    int Ai;
    cin >> Ai;
    if (i % 2)
      Ax[i / 2] = Ai;
    else
      Ay[i / 2] = Ai;
  }

  vector<vector<bool>> dpx(Nx + 1, vector<bool>(20001, false)), dpy(Ny + 1, vector<bool>(20001, false));
  dpx[0][10000] = true;
  dpy[0][10000] = true;
  for (int i = 0; i < Nx; i++)
  {
    for (int j = 10000 - i * 10; j <= 10000 + i * 10; j++)
    {
      if (!dpx[i][j])
        continue;
      dpx[i + 1][j - Ax[i]] = true;
      dpx[i + 1][j + Ax[i]] = true;
    }
  }
  for (int i = 0; i < Ny; i++)
  {
    for (int j = 10000 - i * 10; j <= 10000 + i * 10; j++)
    {
      if (!dpy[i][j])
        continue;
      dpy[i + 1][j - Ay[i]] = true;
      dpy[i + 1][j + Ay[i]] = true;
    }
  }
  cout << (dpx[Nx][10000 + x] && dpy[Ny][10000 + y] ? "Yes" : "No") << endl;
  return 0;
}

Submission Info

Submission Time
Task D - Robot Arms 2
User koshikura
Language C++ (GCC 9.2.1)
Score 400
Code Size 1053 Byte
Status AC
Exec Time 21 ms
Memory 6080 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 5
AC × 27
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_corner_00.txt, 02_corner_01.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt, 03_handmade_05.txt, 03_handmade_06.txt, 03_handmade_07.txt, 03_handmade_08.txt, 03_handmade_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 12 ms 3360 KiB
00_sample_01.txt AC 5 ms 3512 KiB
00_sample_02.txt AC 2 ms 3460 KiB
00_sample_03.txt AC 2 ms 3416 KiB
00_sample_04.txt AC 2 ms 3600 KiB
01_random_00.txt AC 12 ms 5252 KiB
01_random_01.txt AC 17 ms 5848 KiB
01_random_02.txt AC 3 ms 3908 KiB
01_random_03.txt AC 21 ms 6008 KiB
01_random_04.txt AC 15 ms 5952 KiB
01_random_05.txt AC 16 ms 6080 KiB
01_random_06.txt AC 9 ms 5132 KiB
01_random_07.txt AC 16 ms 5944 KiB
01_random_08.txt AC 4 ms 3960 KiB
01_random_09.txt AC 16 ms 6072 KiB
02_corner_00.txt AC 16 ms 5952 KiB
02_corner_01.txt AC 20 ms 6020 KiB
03_handmade_00.txt AC 17 ms 6044 KiB
03_handmade_01.txt AC 17 ms 5928 KiB
03_handmade_02.txt AC 14 ms 5900 KiB
03_handmade_03.txt AC 17 ms 5900 KiB
03_handmade_04.txt AC 16 ms 5984 KiB
03_handmade_05.txt AC 17 ms 5904 KiB
03_handmade_06.txt AC 17 ms 5856 KiB
03_handmade_07.txt AC 15 ms 6044 KiB
03_handmade_08.txt AC 2 ms 3600 KiB
03_handmade_09.txt AC 4 ms 3568 KiB