結果

問題 No.472 平均順位
ユーザー imulanimulan
提出日時 2017-01-28 23:20:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 385 ms / 2,000 ms
コード長 763 bytes
コンパイル時間 1,475 ms
コンパイル使用メモリ 163,908 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 13:28:05
合計ジャッジ時間 5,831 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 10 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 6 ms
4,384 KB
testcase_07 AC 12 ms
4,380 KB
testcase_08 AC 35 ms
4,380 KB
testcase_09 AC 79 ms
4,384 KB
testcase_10 AC 96 ms
4,380 KB
testcase_11 AC 147 ms
4,384 KB
testcase_12 AC 138 ms
4,384 KB
testcase_13 AC 381 ms
4,380 KB
testcase_14 AC 384 ms
4,384 KB
testcase_15 AC 384 ms
4,384 KB
testcase_16 AC 381 ms
4,380 KB
testcase_17 AC 385 ms
4,384 KB
testcase_18 AC 95 ms
4,384 KB
testcase_19 AC 361 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int INF=505050505;
const int N=15001;
int dp[N],nx[N];

int p[5000][4];

int main()
{
    int n,P;
    scanf(" %d %d", &n, &P);

    rep(i,n)
    {
        rep(j,3) scanf(" %d", &p[i][j]);
        p[i][3]=1;
    }

    fill(dp,dp+N,INF);
    dp[0]=0;
    rep(i,n)
    {
        fill(nx,nx+N,INF);
        rep(j,N)rep(k,4)if(j+k<N) nx[j+k] = min(nx[j+k],dp[j]+p[i][k]);

        rep(j,N) dp[j]=nx[j];
    }

    printf("%.10f\n", (double)dp[P]/n);
    return 0;
}
0