結果

問題 No.798 コレクション
ユーザー chocopuuchocopuu
提出日時 2019-03-16 13:45:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,343 bytes
コンパイル時間 1,629 ms
コンパイル使用メモリ 174,296 KB
実行使用メモリ 35,484 KB
最終ジャッジ日時 2023-09-14 15:14:17
合計ジャッジ時間 3,058 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
35,212 KB
testcase_01 AC 12 ms
35,268 KB
testcase_02 AC 12 ms
35,168 KB
testcase_03 AC 12 ms
35,276 KB
testcase_04 AC 12 ms
35,260 KB
testcase_05 AC 12 ms
35,200 KB
testcase_06 AC 12 ms
35,208 KB
testcase_07 AC 12 ms
35,472 KB
testcase_08 AC 12 ms
35,484 KB
testcase_09 AC 12 ms
35,176 KB
testcase_10 AC 12 ms
35,260 KB
testcase_11 AC 11 ms
35,344 KB
testcase_12 AC 12 ms
35,276 KB
testcase_13 AC 15 ms
35,244 KB
testcase_14 AC 17 ms
35,216 KB
testcase_15 AC 16 ms
35,256 KB
testcase_16 AC 14 ms
35,248 KB
testcase_17 AC 15 ms
35,256 KB
testcase_18 AC 18 ms
35,288 KB
testcase_19 AC 18 ms
35,260 KB
testcase_20 AC 14 ms
35,312 KB
testcase_21 AC 13 ms
35,376 KB
testcase_22 AC 15 ms
35,212 KB
testcase_23 AC 12 ms
35,364 KB
testcase_24 AC 19 ms
35,480 KB
testcase_25 AC 19 ms
35,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define FOR(i,n) for(int i = 0;i<n;i++)
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1ll<<60;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};
typedef pair<pint,int>P1;
typedef vector<vint>vvint;

int dp[2020][2020];
 
signed main() {
    IOS();
    int N;
    cin>>N;
    vint a(N),b(N);
    vpint v(N);
    rep(i,0,N){
        cin>>a[i]>>b[i];
        v[i]={b[i],a[i]};
    }
    sort(all(v));
    reverse(all(v));
    
    rep(i,0,2020)rep(j,0,2020)dp[i][j]=INF;
    dp[0][0]=0;
    rep(i,0,N){
        rep(j,0,N){
            if(dp[i][j]==INF)continue;
            chmin(dp[i+1][j+1],dp[i][j]+v[i].se+v[i].fi*j);
            chmin(dp[i+1][j],dp[i][j]);
        }
    }
    cout<<dp[N][N-N/3]<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}
0