結果

問題 No.1430 Coup de Coupon
ユーザー simansiman
提出日時 2021-12-12 20:56:53
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 988 bytes
コンパイル時間 4,028 ms
コンパイル使用メモリ 105,252 KB
実行使用メモリ 199,408 KB
最終ジャッジ日時 2023-09-28 14:19:08
合計ジャッジ時間 6,534 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 94 ms
194,660 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 88 ms
196,076 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

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];
  }

  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