結果

問題 No.2492 Knapsack Problem?
ユーザー yelyel
提出日時 2023-10-06 21:56:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 1,636 ms
コンパイル使用メモリ 171,596 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-06 21:56:03
合計ジャッジ時間 2,276 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
typedef long long ll;
typedef unsigned long long ull;
const int MAX = 1e9;
const int MIN = -1*1e9;
const ll MAXLL = 1e18;
const ll MINLL = -1*1e18;
//const ll MOD = 998244353;
//const ll MOD = 1000000007;
int main()
{
    int N,M; cin >> N >> M;
    vector<pair<int,int>> P(N);
    for(int i = 0; i < N; i++)
    {
        cin >> P[i].second >> P[i].first;
    }
    sort(P.begin(),P.end());

    int Ans = -1;
    for(int i = 0; i < N; i++)
    {
        if(P[i].first > M) break;
        Ans = max(Ans,P[i].second);
    }
    cout << Ans << endl;
    return 0;
}
0