結果

問題 No.1430 Coup de Coupon
ユーザー tnakao0123tnakao0123
提出日時 2021-03-15 00:54:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,579 bytes
コンパイル時間 1,403 ms
コンパイル使用メモリ 97,532 KB
実行使用メモリ 101,632 KB
最終ジャッジ日時 2024-04-24 06:20:36
合計ジャッジ時間 2,948 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 15 ms
24,064 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 95 ms
101,632 KB
testcase_07 AC 102 ms
101,296 KB
testcase_08 AC 16 ms
23,936 KB
testcase_09 AC 35 ms
34,048 KB
testcase_10 AC 48 ms
43,136 KB
testcase_11 AC 58 ms
52,096 KB
testcase_12 AC 76 ms
62,080 KB
testcase_13 AC 92 ms
72,960 KB
testcase_14 AC 80 ms
83,072 KB
testcase_15 AC 87 ms
93,056 KB
testcase_16 AC 91 ms
101,504 KB
testcase_17 AC 96 ms
101,348 KB
testcase_18 AC 78 ms
72,448 KB
testcase_19 AC 74 ms
73,728 KB
testcase_20 AC 39 ms
39,424 KB
testcase_21 AC 8 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 5 ms
9,728 KB
testcase_26 AC 8 ms
11,136 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++)
      if (dp[i][j] < INF) {
	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