結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 218 ms
199,040 KB
testcase_07 AC 219 ms
198,912 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 34 ms
24,064 KB
testcase_10 AC 56 ms
41,984 KB
testcase_11 AC 79 ms
59,904 KB
testcase_12 AC 104 ms
80,256 KB
testcase_13 AC 128 ms
101,760 KB
testcase_14 AC 150 ms
121,856 KB
testcase_15 AC 168 ms
141,568 KB
testcase_16 AC 186 ms
159,360 KB
testcase_17 AC 200 ms
179,072 KB
testcase_18 AC 126 ms
100,736 KB
testcase_19 AC 132 ms
103,552 KB
testcase_20 AC 65 ms
54,272 KB
testcase_21 AC 6 ms
6,144 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 10 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) {
    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);
      }
    }
  }
  cout << *min_element(ALL(dp[N])) << endl;

  return 0;
}
0