結果

問題 No.2329 Nafmo、イカサマをする
ユーザー shirokamishirokami
提出日時 2023-05-28 15:02:39
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 237 ms / 2,000 ms
コード長 2,641 bytes
コンパイル時間 5,100 ms
コンパイル使用メモリ 330,512 KB
実行使用メモリ 35,272 KB
最終ジャッジ日時 2023-08-27 11:16:15
合計ジャッジ時間 7,993 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 7 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 6 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 11 ms
4,736 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 3 ms
4,380 KB
testcase_36 AC 109 ms
18,712 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 115 ms
19,280 KB
testcase_40 AC 4 ms
4,380 KB
testcase_41 AC 237 ms
35,272 KB
testcase_42 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>
using namespace std;
// using namespace __gnu_pbds;
// #include <boost/multiprecision/cpp_int.hpp>
// using Bint = boost::multiprecision::cpp_int;
// #include <atcoder/all>
// using namespace atcoder;
// https://atcoder.github.io/ac-library/production/document_ja/
typedef long long int ll;
typedef long double ld;
constexpr ll mod = 1e9+7;
constexpr ll INF = 9'223'372'036'854'775'807/10;
#define rep(i,n) for (ll i = 0; i < ll(n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < ll(n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using V = vector<ll>;
using P = pair<ll,ll>;
vector<ll> dx = {1, 0, -1, 0, 1, 1, -1, -1};
vector<ll> dy = {0, 1, 0, -1, 1, -1, 1, -1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
struct Edge{ll to, cost;};
using Graph = vector<vector<Edge>>;
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << setprecision(15) << fixed;
  }
} iosetup;
void print(vector<string> &v) {
  for (string s : v) {
    cout << s << '\n';
  }
}
template<typename T>
void print(vector<T> &v, int w = 0) {
  for (int i = 0; i < (int)v.size(); i++) {
    cout << right << setw(w) << v[i] << " \n"[i == (int)v.size() - 1];
  }
}
template<typename T>
void print(vector<vector<T>> &v, int w = 0) {
  for (int i = 0; i < (int)v.size(); i++) {
    print(v[i], w);
  }
}
template<typename T>
void print(const T& arg) {
  cout << arg << '\n';
}
template<typename T, typename... Args>
void print(const T& arg, const Args&... args) {
  cout << arg << ' ';
  print(args...);
}

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  queue<ll> q;
  q.emplace(0);
  vector<ll> b;
  b.emplace_back(0);
  rep(i,k/2) {
    queue<ll> tmp = q;
    while (!tmp.empty()) {
      ll now = tmp.front();
      tmp.pop();
      q.pop();
      rep(j,n) {
        q.emplace(now+a[j]);
        b.emplace_back(now+a[j]);
      }
    }
  }
  queue<ll> q2;
  q2.emplace(0);
  vector<ll> c;
  c.emplace_back(0);
  rep(i,(k+1)/2) {
    queue<ll> tmp = q2;
    while (!tmp.empty()) {
      ll now = tmp.front();
      tmp.pop();
      q2.pop();
      rep(j,n) {
        q2.emplace(now+a[j]);
        c.emplace_back(now+a[j]);
      }
    }
  }
  sort(All(b));
  sort(All(c));
  ll ans = 0;
  rep(i,b.size()) {
    ll now = b[i];
    ll rest = m-now;
    auto itr = upper_bound(All(c), rest);
    ll idx = itr-c.begin();
    if (idx == 0) continue;
    chmax(ans, now+c[idx-1]);
  }
  print(ans);
}
0