結果
| 問題 |
No.798 コレクション
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-14 23:12:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 902 bytes |
| コンパイル時間 | 1,896 ms |
| コンパイル使用メモリ | 161,780 KB |
| 実行使用メモリ | 35,328 KB |
| 最終ジャッジ日時 | 2024-09-19 18:14:13 |
| 合計ジャッジ時間 | 2,680 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll dp[2020][2020];
int main(void) {
ll N;
cin >> N;
ll i, j;
P itm[2020];
for(i=0; i<N; i++) {
cin >> itm[i].sc >> itm[i].ft;
}
sort(itm, itm+N);
reverse(itm, itm+N);
for(i=0; i<2020; i++) {
for(j=0; j<2020; j++) {
dp[i][j]=INF;
}
}
dp[0][0]=0;
for(i=0; i<N; i++) {
for(j=0; j<=N/3; j++) {
chmin(dp[i+1][j], dp[i][j]+itm[i].sc+itm[i].ft*(i-j));
chmin(dp[i+1][j+1], dp[i][j]);
}
}
pt(dp[N][N/3]);
}