結果

問題 No.1430 Coup de Coupon
ユーザー uzzyuzzy
提出日時 2021-03-14 16:04:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 1,519 bytes
コンパイル時間 2,391 ms
コンパイル使用メモリ 185,216 KB
実行使用メモリ 101,788 KB
最終ジャッジ日時 2024-04-23 23:27:58
合計ジャッジ時間 5,518 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 17 ms
43,172 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 59 ms
101,632 KB
testcase_07 AC 60 ms
101,720 KB
testcase_08 AC 59 ms
101,632 KB
testcase_09 AC 132 ms
101,712 KB
testcase_10 AC 163 ms
101,472 KB
testcase_11 AC 186 ms
101,656 KB
testcase_12 AC 196 ms
101,532 KB
testcase_13 AC 194 ms
101,596 KB
testcase_14 AC 179 ms
101,600 KB
testcase_15 AC 157 ms
101,588 KB
testcase_16 AC 129 ms
101,560 KB
testcase_17 AC 99 ms
101,628 KB
testcase_18 AC 200 ms
101,632 KB
testcase_19 AC 202 ms
101,788 KB
testcase_20 AC 81 ms
53,376 KB
testcase_21 AC 10 ms
14,208 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 7 ms
9,856 KB
testcase_26 AC 7 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N, C, P[5000], A[5000], B[5000], a, b;
int dp[5001][5001];
int keisan(int i, int j) {
	if (dp[i][j] != -1) return dp[i][j];
	if (i == 0) return dp[i][j] = 0;

	int ret = 0;
	int k = i - j;
	if (j <= a && j > 0) {
		chmax(ret, keisan(i - 1, j - 1) + min(A[j - 1], P[i - 1]));
	}
	if (k <= b && k > 0) {
		chmax(ret, keisan(i - 1, j) + (B[k - 1] * P[i - 1] / 100));
	}
	return dp[i][j] = ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	cin >> N >> C;
	rep(i, N) cin >> P[i];
	sort(P, P + N);
	reverse(P, P + N);
	rep(i, C) {
		int t, x;
		cin >> t >> x;
		if (t == 1) {
			A[a++] = x;
		}
		else B[b++] = x;
	}
	sort(A, A + a);
	reverse(A, A + a);
	sort(B, B + b);
	reverse(B, B + b);

	rep(i, N + 1) rep(j, C + 1) dp[i][j] = -1;

	int kotae = 0;
	int ab = min(C, N);
	rep(i, a + 1) {
		int j = ab - i;
		if (j >= 0 && j <= b) {
			chmax(kotae, keisan(ab, i));
		}
	}
	rep(i, N) kotae -= P[i];
	co(-kotae);

	Would you please return 0;
}
0