結果

問題 No.798 コレクション
ユーザー 41Toame41Toame
提出日時 2019-03-15 22:18:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,051 bytes
コンパイル時間 1,246 ms
コンパイル使用メモリ 148,944 KB
実行使用メモリ 36,736 KB
最終ジャッジ日時 2023-09-14 13:43:24
合計ジャッジ時間 2,659 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
36,460 KB
testcase_01 AC 13 ms
36,520 KB
testcase_02 AC 13 ms
36,520 KB
testcase_03 AC 13 ms
36,512 KB
testcase_04 AC 14 ms
36,524 KB
testcase_05 AC 13 ms
36,444 KB
testcase_06 AC 13 ms
36,440 KB
testcase_07 AC 13 ms
36,464 KB
testcase_08 AC 13 ms
36,428 KB
testcase_09 AC 13 ms
36,432 KB
testcase_10 AC 13 ms
36,736 KB
testcase_11 AC 14 ms
36,432 KB
testcase_12 AC 13 ms
36,508 KB
testcase_13 AC 17 ms
36,468 KB
testcase_14 AC 19 ms
36,468 KB
testcase_15 AC 18 ms
36,512 KB
testcase_16 AC 16 ms
36,452 KB
testcase_17 AC 17 ms
36,508 KB
testcase_18 AC 21 ms
36,512 KB
testcase_19 AC 20 ms
36,468 KB
testcase_20 AC 16 ms
36,524 KB
testcase_21 AC 15 ms
36,464 KB
testcase_22 AC 19 ms
36,628 KB
testcase_23 AC 13 ms
36,468 KB
testcase_24 AC 21 ms
36,432 KB
testcase_25 AC 21 ms
36,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int dp[2010][2010];// dp[i][j]:= i個目までの商品からj個買った時の最少額

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    pair<int, int> P[100010];
    rep(i, N) cin >> P[i].second >> P[i].first;
    sort(P, P + N, greater<pair<int, int>>());
    rep(i, 2010) rep(j, 2010) dp[i][j] = INF2;
    dp[0][0] = 0;
    rep(i, N) {
        rep(j, N) {
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + P[i].second + P[i].first * j);
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }
    cout << dp[N][(N*2+2)/3] << endl; 



    return 0;
}
0