結果

問題 No.2492 Knapsack Problem?
ユーザー LanatusLanatus
提出日時 2024-01-21 19:51:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 3,111 bytes
コンパイル時間 1,204 ms
コンパイル使用メモリ 107,368 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-21 19:51:44
合計ジャッジ時間 2,206 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>

#define all(v) begin(v), end(v)
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)

using namespace std;

template <class S, class T> inline bool chmax(S &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class S, class T> inline bool chmin(S &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class S> using pqg = priority_queue<S, vector<S>, greater<S>>;
template <class S> using pq = priority_queue<S>;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vvpi = vector<vpi>;
using vvpl = vector<vpl>;

const ll MOD = 1000000007;
const ll MAX = 500000;
const ll INF = 1000000000;
const ll INFLL = 1000000000000000000;

struct mint {
  ll x;

  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator+=(const mint &a) {
    x += a.x;
    if (x >= MOD)
      x -= MOD;
    return *this;
  }
  mint operator-=(const mint &a) {
    if (x < a.x)
      x += MOD;
    x -= a.x;
    return *this;
  }
  mint operator*=(const mint &a) {
    x = x * a.x % MOD;
    return *this;
  }
  mint operator/=(const mint &a) { return *this *= a.inv(); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  mint inv(void) const { return pow(MOD - 2); }
  mint pow(ll a) const {
    if (!a)
      return 1;
    mint t = pow(a >> 1);
    t *= t;
    if (a & 1)
      t *= (*this);
    return t;
  }
  friend ostream &operator<<(ostream &os, const mint &a) {
    os << a.x;
    return os;
  }
};

struct UnionFind {
  vector<int> parent, siz;

  UnionFind(int n) : parent(n), siz(n, 1) {
    for (int i = 0; i < n; ++i)
      parent[i] = i;
  }

  int root(int x) {
    if (parent[x] == x)
      return x;
    return parent[x] = root(parent[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);

    if (x == y)
      return false;

    if (siz[x] > siz[y])
      swap(x, y);

    siz[y] += siz[x];
    parent[x] = y;

    return true;
  }

  int size(int x) { return siz[root(x)]; }

  bool same(int x, int y) { return root(x) == root(y); }
};

long long modpow(long long a, long long n) {
  if (!n)
    return 1;
  if (n % 2)
    return (a * modpow(a, n - 1)) % MOD;
  long long t = modpow(a, n / 2);
  return t * t % MOD;
}

int main(void) {
  int n, m;
  cin >> n >> m;

  int ans = -1;
  for (int i = 0; i < n; ++i) {
    int v, w;
    cin >> v >> w;

    if (w <= m)
      chmax(ans, v);
  }

  cout << ans << endl;
  return 0;
}
0