結果

問題 No.472 平均順位
コンテスト
ユーザー rickytheta
提出日時 2016-12-22 00:13:40
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 625 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 403 ms
コンパイル使用メモリ 53,044 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-26 18:28:27
合計ジャッジ時間 2,909 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <cstdio>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,p;
int a[5252],b[5252],c[5252];
int dp[2][15252];

const int INF = 1<<30;

int main(){
  scanf("%d%d",&n,&p);
  fill(dp[0],dp[0]+3*n+1,INF);
  int cur = 0;
  dp[cur][0] = 0;
  REP(i,n){
    int vs[4] = {0,0,0,1};
    scanf("%d%d%d",vs+0,vs+1,vs+2);
    fill(dp[cur^1],dp[cur^1]+3*n+1,INF);
    REP(k,4)REP(j,3*n+1){
      CHMIN(dp[cur^1][j+k],dp[cur][j]+vs[k]);
    }
    cur ^= 1;
  }
  printf("%.10f\n",(double)dp[cur][p] / n);
  return 0;
}
0