結果

問題 No.3711 Udon, Tempura
コンテスト
ユーザー tnakao0123
提出日時 2026-09-13 15:58:41
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
+ 441µs
コード長 783 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 315 ms
コンパイル使用メモリ 77,696 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-09-13 15:58:46
合計ジャッジ時間 2,486 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 3711.cc:  No.3711 Udon, Tempura - yukicoder
 */

#include<cstdio>
#include<bitset>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_M = 100;
const int MAX_U = 100000;
const int MAX_T = 1000;
const int MAX_S = MAX_U + MAX_M * MAX_T;

/* typedef */

using btst = bitset<MAX_S + 1>;

/* global variables */

int us[MAX_N], ts[MAX_M];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", us + i);
  for (int i = 0; i < m; i++) scanf("%d", ts + i);

  btst dp;
  dp[0] = 1;
  for (int i = 0; i < m; i++) dp |= (dp << ts[i]);

  btst b;
  for (int i = 0; i < n; i++) b |= (dp << us[i]);

  printf("%d\n", (int)b.count());
  
  return 0;
}

0