結果
問題 |
No.1861 Required Number
|
ユーザー |
|
提出日時 | 2022-03-04 23:12:42 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 647 bytes |
コンパイル時間 | 5,564 ms |
コンパイル使用メモリ | 164,564 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 23:16:49 |
合計ジャッジ時間 | 57,748 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 RE * 4 TLE * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int MAXK = 1000; using Line = bitset<MAXK + 1>; int main() { int N, K; cin >> N >> K; vector<int> A(N); for (int &x : A) cin >> x; Line ans; ans.set(0); for (int x : A) ans |= ans << x; if (!ans[K]) { cout << -1 << endl; return 0; } int ret = 0; for (int i = 0; i < N; ++i) { Line ans; ans.set(0); for (int j = 0; j < N; ++j) if (j != i) { ans |= ans << A[j]; } if (!ans[K]) ++ret; } cout << ret << endl; }