結果

問題 No.1430 Coup de Coupon
ユーザー materialmaterial
提出日時 2021-03-15 18:24:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 1,334 bytes
コンパイル時間 2,632 ms
コンパイル使用メモリ 204,592 KB
実行使用メモリ 199,168 KB
最終ジャッジ日時 2024-04-24 21:13:51
合計ジャッジ時間 4,631 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 179 ms
199,040 KB
testcase_07 AC 182 ms
199,168 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 29 ms
24,064 KB
testcase_10 AC 51 ms
42,112 KB
testcase_11 AC 69 ms
60,032 KB
testcase_12 AC 92 ms
80,256 KB
testcase_13 AC 111 ms
101,632 KB
testcase_14 AC 126 ms
121,728 KB
testcase_15 AC 143 ms
141,696 KB
testcase_16 AC 155 ms
159,488 KB
testcase_17 AC 171 ms
178,944 KB
testcase_18 AC 108 ms
100,608 KB
testcase_19 AC 110 ms
103,424 KB
testcase_20 AC 58 ms
54,272 KB
testcase_21 AC 5 ms
6,144 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 9 ms
9,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1e+12;

#define REP(i, n) for (ll i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()

int main()
{
  ll N, C;
  cin >> N >> C;

  vector<ll> P(N);
  REP(n, N) { cin >> P[n]; }
  sort(ALL(P), greater<ll>());

  vector<ll> cs1, cs2;
  REP(c, C) {
    ll T, X;
    cin >> T >> X;

    switch (T) {
    case 1:
      cs1.push_back(X);
      break;
    case 2:
      cs2.push_back(X);
      break;
    }
  }
  sort(ALL(cs1), greater<ll>());
  sort(ALL(cs2), greater<ll>());

  ll c1 = cs1.size(), c2 = cs2.size();
  vector<vector<ll>> dp(N + 1, vector<ll>(c1 + 1, INF));
  dp[0][0] = 0;
  REP(i, N) {
    if (i < C) {
      REP(j, c1 + 1) {
        if (j > i) { continue; }
        ll k = i - j;

        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + P[i]);

        if (j < c1) {
          ll cost = max(static_cast<ll>(0), P[i] - cs1[j]);
          dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + cost);
        }

        if (k < c2) {
          ll cost = P[i] - ((P[i] / 100) * cs2[k]);
          dp[i + 1][j + 0] = min(dp[i + 1][j + 0], dp[i][j] + cost);
        }
      }
    } else {
      REP(j, c1 + 1) {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + P[i]);
      }
    }
  }
  cout << *min_element(ALL(dp[N])) << endl;

  return 0;
}
0