結果

問題 No.1430 Coup de Coupon
ユーザー simansiman
提出日時 2021-12-12 20:58:25
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 1,031 bytes
コンパイル時間 1,191 ms
コンパイル使用メモリ 105,772 KB
実行使用メモリ 198,800 KB
最終ジャッジ日時 2023-09-28 14:21:49
合計ジャッジ時間 3,811 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 103 ms
160,000 KB
testcase_04 AC 4 ms
4,384 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 100 ms
155,716 KB
testcase_07 AC 99 ms
156,212 KB
testcase_08 AC 99 ms
155,540 KB
testcase_09 AC 99 ms
155,988 KB
testcase_10 AC 100 ms
156,220 KB
testcase_11 AC 99 ms
155,564 KB
testcase_12 AC 99 ms
156,260 KB
testcase_13 AC 100 ms
156,440 KB
testcase_14 AC 99 ms
155,672 KB
testcase_15 AC 100 ms
155,528 KB
testcase_16 AC 99 ms
155,424 KB
testcase_17 AC 103 ms
155,532 KB
testcase_18 AC 102 ms
198,800 KB
testcase_19 AC 101 ms
197,728 KB
testcase_20 AC 39 ms
101,920 KB
testcase_21 AC 27 ms
81,396 KB
testcase_22 AC 2 ms
5,724 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
9,672 KB
testcase_25 AC 17 ms
58,816 KB
testcase_26 AC 13 ms
42,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

ll A[5010];
ll B[5010];
ll dp[5010][5010];

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

  for (int i = 0; i < N; ++i) {
    cin >> P[i];
  }
  sort(P.begin(), P.end(), greater<ll>());

  int ia = 0;
  int ib = 0;
  for (int i = 0; i < C; ++i) {
    ll t, x;
    cin >> t >> x;

    if (t == 1) {
      A[ia++] = x;
    } else {
      B[ib++] = x;
    }
  }

  sort(A, A + ia, greater<ll>());
  sort(B, B + ib, greater<ll>());

  for (int i = N; i >= 0; --i) {
    for (int j = 0; j < i + 1; ++j) {
      if (i == N) {
        dp[i][j] = 0;
      } else {
        ll p1 = max(0LL, P[i] - A[j]) + dp[i + 1][j + 1];
        ll p2 = P[i] * (100 - B[i - j]) / 100 + dp[i + 1][j];
        dp[i][j] = min(p1, p2);
      }
    }
  }

  cout << dp[0][0] << endl;

  return 0;
}
0