結果

問題 No.1862 Copy and Paste
ユーザー ぷらぷら
提出日時 2022-01-05 15:40:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 679 bytes
コンパイル時間 1,780 ms
コンパイル使用メモリ 193,852 KB
最終ジャッジ日時 2025-01-27 08:48:09
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 RE * 1
other AC * 6 RE * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr long long inf = 1001001001001001001;
long long dp[5005][5005];

int main() {
    int A,B,N;
    cin >> A >> B >> N;
    if(N > 5000) {
        assert(0);
    }
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= N; j++) {
            dp[i][j] = inf;
        }
    }
    dp[1][0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= N; j++) {
            dp[min(N,i+j)][j] = min(dp[min(N,i+j)][j],dp[i][j]+B);
            dp[i][i] = min(dp[i][i],dp[i][j]+A);
        }
    }
    long long ans = inf;
    for(int i = 0; i <= N; i++) {
        ans = min(ans,dp[N][i]);
    }
    cout << ans << endl;
}
0