結果

問題 No.2401 Dirty Shoes and Stairs
ユーザー tnakao0123
提出日時 2023-08-07 10:49:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 516 ms
コンパイル使用メモリ 41,800 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-07 14:43:15
合計ジャッジ時間 2,095 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2401.cc:  No.2401 Dirty Shoes and Stairs - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int as[MAX_N], bs[MAX_N];
bool fs[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n, m1, m2;
  scanf("%d", &n);
  scanf("%d", &m1);
  for (int i = 0; i < m1; i++) scanf("%d", as + i);
  scanf("%d", &m2);
  for (int i = 0; i < m2; i++) scanf("%d", bs + i);

  fs[0] = fs[n] = true;
  for (int i = 0, s = 0; i < m1; i++)
    s += as[i], fs[s] = true;
  for (int i = 0, s = n; i < m2; i++)
    s -= bs[i], fs[s] = true;

  int cnt = 0;
  for (int i = 0; i <= n; i++)
    if (! fs[i]) cnt++;

  printf("%d\n", cnt);
  return 0;
}
0