結果

問題 No.798 コレクション
ユーザー eQeeQe
提出日時 2019-04-14 23:12:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 902 bytes
コンパイル時間 3,026 ms
コンパイル使用メモリ 163,512 KB
実行使用メモリ 35,564 KB
最終ジャッジ日時 2023-10-19 22:12:58
合計ジャッジ時間 4,857 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
35,564 KB
testcase_01 AC 11 ms
35,564 KB
testcase_02 AC 12 ms
35,564 KB
testcase_03 AC 11 ms
35,564 KB
testcase_04 AC 11 ms
35,564 KB
testcase_05 AC 12 ms
35,564 KB
testcase_06 AC 11 ms
35,564 KB
testcase_07 AC 11 ms
35,564 KB
testcase_08 AC 12 ms
35,564 KB
testcase_09 AC 11 ms
35,564 KB
testcase_10 AC 11 ms
35,564 KB
testcase_11 AC 11 ms
35,564 KB
testcase_12 AC 11 ms
35,564 KB
testcase_13 AC 13 ms
35,564 KB
testcase_14 AC 14 ms
35,564 KB
testcase_15 AC 14 ms
35,564 KB
testcase_16 AC 13 ms
35,564 KB
testcase_17 AC 14 ms
35,564 KB
testcase_18 AC 15 ms
35,564 KB
testcase_19 AC 14 ms
35,564 KB
testcase_20 AC 13 ms
35,564 KB
testcase_21 AC 13 ms
35,564 KB
testcase_22 AC 14 ms
35,564 KB
testcase_23 AC 11 ms
35,564 KB
testcase_24 AC 14 ms
35,564 KB
testcase_25 AC 15 ms
35,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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]);
}
0