結果
| 問題 |
No.1430 Coup de Coupon
|
| コンテスト | |
| ユーザー |
uzzy
|
| 提出日時 | 2021-03-14 16:04:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 168 ms / 2,000 ms |
| コード長 | 1,519 bytes |
| コンパイル時間 | 2,517 ms |
| コンパイル使用メモリ | 187,800 KB |
| 実行使用メモリ | 101,660 KB |
| 最終ジャッジ日時 | 2024-11-06 05:50:52 |
| 合計ジャッジ時間 | 5,149 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#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;
}
uzzy