結果

問題 No.3713 海底探索
ユーザー GOTKAKO
提出日時 2026-09-14 19:10:33
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 706µs
コード長 545 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,188 ms
コンパイル使用メモリ 214,740 KB
実行使用メモリ 10,028 KB
最終ジャッジ日時 2026-09-14 19:10:38
合計ジャッジ時間 2,941 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,A,B; cin >> N >> A >> B;
    vector<vector<int>> dp(N+1,vector<int>(A+1,B+1));
    dp.at(0).at(0) = 0;
    for(int t=0; t<N; t++){
        int x,y; cin >> x >> y;
        for(int i=N-1; i>=0; i--) for(int k=0; k<=A-x; k++) dp.at(i+1).at(k+x) = min(dp.at(i+1).at(k+x),dp.at(i).at(k)+y);
    }
    int answer = 0;
    for(int i=1; i<=N; i++) for(auto b : dp.at(i)) if(b <= B) answer = i;
    cout << answer << endl;
}
0