結果

問題 No.1430 Coup de Coupon
ユーザー kwm_tkwm_t
提出日時 2021-03-14 15:58:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,675 bytes
コンパイル時間 1,570 ms
コンパイル使用メモリ 170,756 KB
実行使用メモリ 39,040 KB
最終ジャッジ日時 2024-04-23 23:24:50
合計ジャッジ時間 3,024 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 21 ms
23,552 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 21 ms
23,680 KB
testcase_07 AC 21 ms
23,552 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 23 ms
13,824 KB
testcase_10 AC 38 ms
22,656 KB
testcase_11 AC 50 ms
29,312 KB
testcase_12 AC 62 ms
34,816 KB
testcase_13 AC 62 ms
38,144 KB
testcase_14 AC 64 ms
39,040 KB
testcase_15 AC 59 ms
37,760 KB
testcase_16 AC 51 ms
35,328 KB
testcase_17 AC 38 ms
30,592 KB
testcase_18 AC 63 ms
37,888 KB
testcase_19 AC 63 ms
38,272 KB
testcase_20 AC 59 ms
38,272 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 6 ms
7,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
int dp[5001][5001];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, C;
	cin >> N >> C;
	vector<int>P(N);
	int sum = 0;
	rep(i, N) {
		cin >> P[i];
		sum += P[i];
	}
	sort(allR(P));
	vector<int> C1;
	vector<int> C2;
	rep(i, C) {
		int t, x;
		cin >> t >> x;
		if (1 == t) {
			C1.push_back(x);
		}
		else {
			C2.push_back(x);
		}
	}
	sort(allR(C1));
	sort(allR(C2));
	dp[0][0] = 0;
	rep(i, C1.size() + 1) {
		rep(j, C2.size() + 1) {
			if ((i + j + 1) > N) {
				//商品がない
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
				dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
				continue;
			}
			{
				if (i < C1.size()) {
					int v = max(0, P[i + j] - C1[i]);
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + P[i + j] - v);
				}
				else {
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
				}
			}
			{
				if (j < C2.size()) {
					int v = P[i + j] * (100 - C2[j]) / 100;
					dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + P[i + j] - v);
				}
				else {
					dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
				}
			}
		}
	}
	cout << sum - dp[C1.size()][C2.size()] << endl;
	return 0;
}
0