結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー |
|
提出日時 | 2017-12-19 20:34:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 346 bytes |
コンパイル時間 | 2,353 ms |
コンパイル使用メモリ | 192,836 KB |
最終ジャッジ日時 | 2025-01-05 05:54:37 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | int n, k; scanf("%d%d", &n, &k); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | int a_i; scanf("%d", &a_i); | ~~~~~^~~~~~~~~~~~
ソースコード
#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;}