結果

問題 No.1430 Coup de Coupon
ユーザー tnakao0123tnakao0123
提出日時 2021-03-15 00:52:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,567 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 97,312 KB
実行使用メモリ 101,632 KB
最終ジャッジ日時 2024-04-24 06:16:31
合計ジャッジ時間 3,248 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 14 ms
23,808 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 142 ms
101,632 KB
testcase_07 WA -
testcase_08 AC 15 ms
23,808 KB
testcase_09 AC 32 ms
34,048 KB
testcase_10 AC 46 ms
43,008 KB
testcase_11 AC 57 ms
51,968 KB
testcase_12 AC 71 ms
62,208 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 91 ms
72,448 KB
testcase_19 WA -
testcase_20 AC 45 ms
39,424 KB
testcase_21 AC 9 ms
13,056 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 6 ms
9,856 KB
testcase_26 AC 9 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1430.cc:  No.1430 Coup de Coupon - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 5000;
const int MAX_C = 5000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int ps[MAX_N], qs[MAX_C], rs[MAX_C];
int dp[MAX_N + 1][MAX_C + 1];

/* subroutines */

inline void setmin(int &a, int b) { if (a > b) a = b; }

/* main */

int main() {
  int n, c;
  scanf("%d%d", &n, &c);

  for (int i = 0; i < n; i++) scanf("%d", ps + i);
  sort(ps, ps + n, greater<int>());

  int qn = 0, rn = 0;
  for (int i = 0; i < c; i++) {
    int t, x;
    scanf("%d%d", &t, &x);
    if (t == 1) qs[qn++] = x;
    else rs[rn++] = x;
  }

  sort(qs, qs + qn, greater<int>());
  sort(rs, rs + rn, greater<int>());

  for (int i = 0; i <= n; i++) fill(dp[i], dp[i] + qn + 1, INF);
  dp[0][0] = 0;

  for (int i = 0; i < n; i++)
    for (int j = 0; j <= qn; j++) {
      int k = i - j;
      if (j < qn)
	  setmin(dp[i + 1][j + 1], dp[i][j] + max(ps[i] - qs[j], 0));
      if (k < rn)
	setmin(dp[i + 1][j], dp[i][j] + ps[i] / 100 * (100 - rs[k]));
      else
	setmin(dp[i + 1][j], dp[i][j] + ps[i]);
    }

  int mind = INF;
  for (int j = 0; j <= qn; j++) setmin(mind, dp[n][j]);
  printf("%d\n", mind);
  return 0;
}
0