結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー | tnakao0123 |
提出日時 | 2017-12-18 13:43:32 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 940 bytes |
コンパイル時間 | 659 ms |
コンパイル使用メモリ | 83,252 KB |
実行使用メモリ | 5,504 KB |
最終ジャッジ日時 | 2024-05-09 11:20:41 |
合計ジャッジ時間 | 1,742 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 5 ms
5,376 KB |
testcase_03 | AC | 11 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 17 ms
5,376 KB |
testcase_06 | AC | 33 ms
5,376 KB |
testcase_07 | AC | 34 ms
5,504 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 26 ms
5,376 KB |
testcase_11 | AC | 31 ms
5,376 KB |
testcase_12 | AC | 16 ms
5,376 KB |
testcase_13 | AC | 11 ms
5,376 KB |
testcase_14 | AC | 13 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:45:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 45 | scanf("%d%d", &n, &k); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:47:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | for (int i = 0; i < n; i++) scanf("%d", &as[i]); | ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 617.cc: No.617 Nafmo、買い出しに行く - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int MAX_N = 20; const int MAX_K = 2000000; /* typedef */ /* global variables */ int as[MAX_N]; bool dp[MAX_K + 1]; /* subroutines */ /* main */ int main() { int n, k; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) scanf("%d", &as[i]); dp[0] = true; for (int i = 0; i < n; i++) { int &ai = as[i]; for (int j = k - ai; j >= 0; j--) dp[j + ai] |= dp[j]; } for (int j = k; j >= 0; j--) if (dp[j]) { printf("%d\n", j); break; } return 0; }