結果

問題 No.798 コレクション
ユーザー sinsincoscossinsincoscos
提出日時 2019-03-15 23:02:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 943 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 70,176 KB
実行使用メモリ 19,204 KB
最終ジャッジ日時 2023-09-14 14:05:33
合計ジャッジ時間 1,755 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 11 ms
15,784 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 8 ms
13,456 KB
testcase_17 AC 10 ms
15,620 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 17 ms
19,112 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
int N;
int dp[2010][2010] = {};
int A[2010],B[2010];
vector<P> v;
int main(){
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> A[i] >> B[i];
        v.push_back({B[i],i});
    }
    v.push_back(P(1e9,1e9));
    sort(v.begin(),v.end(),greater<P>());
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            dp[i][j] = 1e9;
        }
    }
    for(int i=1;i<=N;i++){
        int id = v[i].second;
     //   cerr << B[id] << endl;
        for(int j=0;j<=N;j++){
            if(j==0) dp[i][j] = min(dp[i-1][j],A[id]);
            else dp[i][j] = min(min(dp[i][j],dp[i-1][j]),dp[i-1][j-1]+A[id]+j*B[id]);
        }
    }
    int day;
    day = N-N/3;
    /*for(int i=1;i<=N;i++){
        for(int j=0;j<=N;j++){
            cerr << dp[i][j] << " ";
        }
        cerr << endl;
    }
*/    cout << dp[N][day-1] << endl;
}
0