結果
| 問題 | No.617 Nafmo、買い出しに行く | 
| コンテスト | |
| ユーザー |  hamray | 
| 提出日時 | 2018-01-31 22:26:15 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                RE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 457 bytes | 
| コンパイル時間 | 548 ms | 
| コンパイル使用メモリ | 62,272 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-30 00:00:34 | 
| 合計ジャッジ時間 | 4,661 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | RE * 2 | 
| other | RE * 20 | 
コンパイルメッセージ
main.cpp: In function ‘int dfs(int, int)’:
main.cpp:13:8: warning: control reaches end of non-void function [-Wreturn-type]
   13 |     dfs(i+1, sum);
      |     ~~~^~~~~~~~~~
            
            ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int N, K, ans = 0;
vector<int> a;
int dfs(int i, int sum){
    if(sum > K || i >= N) return 0;
    ans = max(sum, ans);
    dfs(i+1, sum+a[i+1]);
    dfs(i+1, sum);
}
int main(){
    cin >> N >> K;
    int temp;
    for(int i=0; i<N; ++i){
        cin >> temp;
        a.push_back(temp);
    }
    dfs(0, 0);
    dfs(0, a[0]);
    
    cout << ans << endl;
}
            
            
            
        