結果

問題 No.798 コレクション
ユーザー chocoruskchocorusk
提出日時 2019-03-15 21:46:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 712 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 62,208 KB
実行使用メモリ 33,620 KB
最終ジャッジ日時 2023-09-14 13:20:58
合計ジャッジ時間 1,786 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 9 ms
24,232 KB
testcase_14 AC 11 ms
30,368 KB
testcase_15 AC 10 ms
28,236 KB
testcase_16 AC 7 ms
19,920 KB
testcase_17 AC 8 ms
24,352 KB
testcase_18 AC 14 ms
32,940 KB
testcase_19 AC 12 ms
30,180 KB
testcase_20 AC 7 ms
21,852 KB
testcase_21 AC 7 ms
20,020 KB
testcase_22 AC 10 ms
28,080 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 13 ms
33,620 KB
testcase_25 AC 14 ms
33,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
    int n; cin>>n;
    int ind[2001];
    ll a[2001], b[2001];
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i];
        ind[i]=i;
    }
    sort(ind, ind+n, [&](int i, int j){ return b[i]>b[j];});
    ll dp[2001][2001];
    for(int i=0; i<=n; i++){
        for(int j=0; j<=i; j++){
            dp[i][j]=1e16;
        }
    }
    dp[0][0]=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<=i; j++){
            int t=ind[i];
            dp[i+1][j]=min(dp[i][j], dp[i+1][j]);
            dp[i+1][j+1]=min(dp[i][j]+a[t]+(ll)j*b[t], dp[i+1][j+1]);
        }
    }
    cout<<dp[n][(2*n+2)/3]<<endl;
    return 0;
}
0