結果

問題 No.472 平均順位
ユーザー rickytheta
提出日時 2016-12-22 00:18:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 35,428 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-17 14:09:00
合計ジャッジ時間 2,235 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |   scanf("%d%d",&n,&p);
      |   ~~~~~^~~~~~~~~~~~~~
main.cpp:17:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |   REP(i,n)scanf("%d%d%d",vs[i]+0,vs[i]+1,vs[i]+2);
      |           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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 dp[2][15252];
int vs[5252][4];

const int INF = 1<<30;

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