結果

問題 No.472 平均順位
ユーザー rickytheta
提出日時 2016-12-22 00:13:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 335 ms / 2,000 ms
コード長 625 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 35,548 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-17 14:06:44
合計ジャッジ時間 3,084 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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:22:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |     scanf("%d%d%d",vs+0,vs+1,vs+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 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