結果
問題 |
No.617 Nafmo、買い出しに行く
|
ユーザー |
|
提出日時 | 2017-12-19 20:35:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 401 bytes |
コンパイル時間 | 3,298 ms |
コンパイル使用メモリ | 216,584 KB |
最終ジャッジ日時 | 2025-01-05 05:54:51 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | int n, k; scanf("%d%d", &n, &k); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:13:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | int a_i; scanf("%d", &a_i); | ~~~~~^~~~~~~~~~~~
ソースコード
#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include <bits/stdc++.h> using namespace std; constexpr int max_k = 2e6; int main() { int n, k; scanf("%d%d", &n, &k); assert (k <= max_k); bitset<max_k + 1> dp; dp[0] = true; while (n --) { int a_i; scanf("%d", &a_i); dp |= dp << a_i; } while (not dp[k]) k --; printf("%d\n", k); return 0; }