提出 #53726297


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i, x) for (int i = 0; i < (x); i++)

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> A(N), B(N), C(N), D(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N) cin >> C[i];
  rep(i, N) cin >> D[i];
  vector<ll> AB(N * N), CD(N * N);
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      AB[i * N + j] = A[i] + B[j];
      CD[i * N + j] = C[i] + D[j];
    }
  }

  sort(CD.begin(), CD.end());
  string ans = "No";
  for (int i = 0; i < (ll)AB.size(); i++)
  {
    auto it = lower_bound(CD.begin(), CD.end(), K - AB[i]);
    if (it != CD.end() && *it == K - AB[i])
    {
      ans = "Yes";
      break;
    }
  }

  cout << ans << endl;
  return 0;
}

提出情報

提出日時
問題 A14 - Four Boxes
ユーザ ryoh1004
言語 C++ 23 (gcc 12.2)
得点 1000
コード長 772 Byte
結果 AC
実行時間 72 ms
メモリ 17956 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 1000 / 1000
結果
AC × 1
AC × 41
セット名 テストケース
Sample sample_01.txt
All 10_random_small_00.txt, 10_random_small_01.txt, 10_random_small_02.txt, 10_random_small_03.txt, 10_random_small_04.txt, 10_random_small_05.txt, 10_random_small_06.txt, 10_random_small_07.txt, 10_random_small_08.txt, 10_random_small_09.txt, 10_random_small_10.txt, 10_random_small_11.txt, 10_random_small_12.txt, 10_random_small_13.txt, 10_random_small_14.txt, 10_random_small_15.txt, 10_random_small_16.txt, 10_random_small_17.txt, 10_random_small_18.txt, 10_random_small_19.txt, 20_random_large_00.txt, 20_random_large_01.txt, 20_random_large_02.txt, 20_random_large_03.txt, 20_random_large_04.txt, 20_random_large_05.txt, 20_random_large_06.txt, 20_random_large_07.txt, 20_random_large_08.txt, 20_random_large_09.txt, 20_random_large_10.txt, 20_random_large_11.txt, 20_random_large_12.txt, 20_random_large_13.txt, 20_random_large_14.txt, 20_random_large_15.txt, 20_random_large_16.txt, 20_random_large_17.txt, 20_random_large_18.txt, 20_random_large_19.txt, sample_01.txt
ケース名 結果 実行時間 メモリ
10_random_small_00.txt AC 1 ms 3564 KiB
10_random_small_01.txt AC 1 ms 3612 KiB
10_random_small_02.txt AC 1 ms 3512 KiB
10_random_small_03.txt AC 1 ms 3620 KiB
10_random_small_04.txt AC 1 ms 3492 KiB
10_random_small_05.txt AC 1 ms 3608 KiB
10_random_small_06.txt AC 1 ms 3524 KiB
10_random_small_07.txt AC 1 ms 3536 KiB
10_random_small_08.txt AC 1 ms 3512 KiB
10_random_small_09.txt AC 1 ms 3564 KiB
10_random_small_10.txt AC 1 ms 3512 KiB
10_random_small_11.txt AC 1 ms 3476 KiB
10_random_small_12.txt AC 1 ms 3560 KiB
10_random_small_13.txt AC 1 ms 3548 KiB
10_random_small_14.txt AC 1 ms 3536 KiB
10_random_small_15.txt AC 1 ms 3420 KiB
10_random_small_16.txt AC 1 ms 3504 KiB
10_random_small_17.txt AC 1 ms 3452 KiB
10_random_small_18.txt AC 1 ms 3488 KiB
10_random_small_19.txt AC 1 ms 3496 KiB
20_random_large_00.txt AC 27 ms 8980 KiB
20_random_large_01.txt AC 72 ms 17956 KiB
20_random_large_02.txt AC 47 ms 12868 KiB
20_random_large_03.txt AC 44 ms 12304 KiB
20_random_large_04.txt AC 69 ms 17320 KiB
20_random_large_05.txt AC 38 ms 10216 KiB
20_random_large_06.txt AC 34 ms 10312 KiB
20_random_large_07.txt AC 9 ms 5000 KiB
20_random_large_08.txt AC 31 ms 9512 KiB
20_random_large_09.txt AC 40 ms 11752 KiB
20_random_large_10.txt AC 54 ms 14412 KiB
20_random_large_11.txt AC 22 ms 8056 KiB
20_random_large_12.txt AC 10 ms 5188 KiB
20_random_large_13.txt AC 6 ms 4292 KiB
20_random_large_14.txt AC 2 ms 3496 KiB
20_random_large_15.txt AC 19 ms 7340 KiB
20_random_large_16.txt AC 21 ms 7636 KiB
20_random_large_17.txt AC 17 ms 6548 KiB
20_random_large_18.txt AC 44 ms 11772 KiB
20_random_large_19.txt AC 55 ms 14416 KiB
sample_01.txt AC 1 ms 3488 KiB