結果

問題 No.472 平均順位
ユーザー eQeeQe
提出日時 2019-01-16 21:53:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 275 ms / 2,000 ms
コード長 1,295 bytes
コンパイル時間 683 ms
コンパイル使用メモリ 73,380 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 02:50:37
合計ジャッジ時間 2,651 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 10 ms
4,376 KB
testcase_10 AC 7 ms
4,384 KB
testcase_11 AC 26 ms
4,380 KB
testcase_12 AC 19 ms
4,380 KB
testcase_13 AC 63 ms
4,380 KB
testcase_14 AC 238 ms
4,376 KB
testcase_15 AC 63 ms
4,380 KB
testcase_16 AC 275 ms
4,380 KB
testcase_17 AC 275 ms
4,384 KB
testcase_18 AC 20 ms
4,380 KB
testcase_19 AC 32 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N, P;
    cin >> N >> P;
    ll i, j;
    ll a[N+5], b[N+5], c[N+5];
    ll dp[P+5];
    
    
    for(i=0; i<N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    
    for(i=1; i<=P; i++)
        dp[i]=INF;
    
    dp[0]=0;
    for(i=0; i<N; i++) {
        for(j=P; j>=0; j--) {
            dp[j]=dp[j]+a[i];
            if(j>=1 && dp[j-1]!=-1)
                chmin(dp[j], dp[j-1]+b[i]);
            if(j>=2 && dp[j-2]!=-1)
                chmin(dp[j], dp[j-2]+c[i]);
            if(j>=3 && dp[j-3]!=-1)
                chmin(dp[j], dp[j-3]+1);
        }
    }
    
    printf("%.10f\n", (double)(dp[P])/(double)N);
    
}

0