結果

問題 No.472 平均順位
ユーザー Asdf_QwertyZAsdf_QwertyZ
提出日時 2018-06-05 22:31:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 503 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 44,976 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 22:36:35
合計ジャッジ時間 3,233 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

constexpr int MAX_N = 5000;
using ll = long long;
constexpr ll INF = std::numeric_limits<ll>::max()>>2;

ll N, P;
ll a[3][MAX_N];
ll dp[2][15001];

void chmin( ll &a, ll b )
{ a = std::min( a, b ); }

int main()
{
  scanf( "%lld%lld", &N, &P );
  rep( i, N )
    scanf( "%lld%lld%lld", &a[0][i], &a[1][i], &a[2][i] );

  dp[0][P] = 0;

  rep( i, N )
  {
    rep( j, P+1 )
      dp[(i+1)%2][j] = INF;

    rep( j, P+1 )
    {
      rep( k, 4 ) if( j-k >= 0 )
        chmin( dp[(i+1)%2][j-k], dp[i%2][j]+(k==3?1:a[k][i]) );
    }
  }

  printf( "%lf\n", (double)dp[N%2][0]/N );
  
  return 0;
}
0