結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2017-12-23 08:10:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 700 bytes |
コンパイル時間 | 449 ms |
コンパイル使用メモリ | 64,476 KB |
実行使用メモリ | 66,560 KB |
最終ジャッジ日時 | 2024-12-17 16:11:36 |
合計ジャッジ時間 | 4,285 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 WA * 1 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <sstream> #include <cmath> using namespace std; int n = 0; int nums[1001]; int b[1001][30100]; int ans = 0; void dfs(int i, int sum, bool judge) { if (i == n) { ans = max(ans, sum); /*cout << i << " " << ans << endl;*/ return; } if(b[i][sum] !=0){ return; } dfs(i + 1, sum, false); b[i+1][sum] =1; if (!judge) { dfs(i + 1, sum + nums[i], true); /* b[i+1][sum+nums[i]] =1;*/ }/* else { dfs(i + 1, sum, false); }*/ return; } int main() { cin >> n; int tmp = 0; for (int i = 0; i < n; i++) { cin >> tmp; nums[i] = tmp; } dfs(0, 0, false); cout << ans << endl; return 0; }