結果

問題 No.3711 Udon, Tempura
ユーザー Nooko
提出日時 2026-11-08 16:58:42
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 862 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,313 ms
コンパイル使用メモリ 345,812 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2026-11-08 16:58:48
合計ジャッジ時間 5,894 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h> 

using i64 = long long; 
using u64 = unsigned long long; 
using u32 = unsigned; 

using u128 = unsigned __int128; 
using i128 = __int128; 

void solve() {
	int N, M; std::cin >> N >> M;
	std::vector<i64> U(N), T(M);
	for(int i = 0; i < N; i ++) std::cin >> U[i];
	for(int i = 0; i < M; i ++) std::cin >> T[i];
	int Z = std::accumulate(T.begin(), T.end(), 0);
	
	std::vector<bool> dp(1e5 + 7);
	dp[0] = true;
	for(int i = 0; i < M; i ++) {
		for(int j = Z; j >= T[i]; j --) {
			dp[j] = dp[j - T[i]];
		}
	}

	std::set<i64> s;
	for(int i = 0; i < 1e5 + 7; i ++) {
		if(!dp[i]) continue;
		for(int j = 0; j < N; j ++) {
			s.insert(U[j] + i);
		}
	}

	std::cout << (int)s.size();
} 

int main() { 
	std::ios::sync_with_stdio(false); 
	std::cin.tie(nullptr); 

	int T = 1; 
	//std::cin >> T; 

	while (T--) { 
		solve(); 
	} 
	return 0; 
}
0