結果
問題 |
No.1861 Required Number
|
ユーザー |
![]() |
提出日時 | 2024-11-01 12:58:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 570 bytes |
コンパイル時間 | 2,175 ms |
コンパイル使用メモリ | 196,048 KB |
最終ジャッジ日時 | 2025-02-25 01:59:50 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 WA * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n, k; cin >> n >> k; vector<int> a(n); bitset<200001> dp; dp[0] = 1; for (int i = 0; i < n; i++) { cin >> a[i]; dp |= dp << a[i]; } if (dp[k]) { int ans = 0; for (int i = 0; i < n; i++) { if (!dp[k + a[i]]) { ans++; } } cout << ans << endl; } else { cout << -1 << endl; } }