結果

問題 No.798 コレクション
ユーザー ShibuyapShibuyap
提出日時 2020-08-03 05:42:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,052 bytes
コンパイル時間 1,806 ms
コンパイル使用メモリ 206,360 KB
実行使用メモリ 34,660 KB
最終ジャッジ日時 2023-09-29 13:18:44
合計ジャッジ時間 3,506 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 8 ms
16,976 KB
testcase_14 AC 11 ms
25,696 KB
testcase_15 AC 9 ms
22,272 KB
testcase_16 AC 6 ms
11,968 KB
testcase_17 AC 7 ms
17,452 KB
testcase_18 AC 15 ms
32,804 KB
testcase_19 AC 12 ms
26,680 KB
testcase_20 AC 6 ms
12,536 KB
testcase_21 AC 5 ms
11,240 KB
testcase_22 AC 9 ms
22,216 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 16 ms
34,580 KB
testcase_25 AC 15 ms
34,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    vector<P> v(n);
    rep(i,n) cin >> v[i].second >> v[i].first;
    sort(v.begin(), v.end(), greater<P>());
    ll a[n], b[n];
    rep(i,n){
        a[i] = v[i].second;
        b[i] = v[i].first;
    }
    ll dp[n][n+1];
    ll INF = 1001001001001001001;
    rep(i,n)rep(j,n+1)dp[i][j] = INF;

    rep(i,n){
        if(i==0){
            dp[0][0] = 0;
            dp[0][1] = a[0];
        }else{
            rep(j,n+1){
                dp[i][j] = dp[i-1][j];
                if(j==0)continue;
                ll tmp = dp[i-1][j-1] + a[i] + b[i]*(j-1);
                dp[i][j] = min(dp[i][j], tmp);
            } 
        }
    }

    ll ans = dp[n-1][n-n/3];
    cout << ans << endl;
    return 0;
}
 
 
0