結果

問題 No.472 平均順位
ユーザー rickythetarickytheta
提出日時 2016-12-22 00:13:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 335 ms / 2,000 ms
コード長 625 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 35,676 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-09 20:40:04
合計ジャッジ時間 3,057 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 16 ms
5,376 KB
testcase_10 AC 22 ms
5,376 KB
testcase_11 AC 51 ms
5,376 KB
testcase_12 AC 45 ms
5,376 KB
testcase_13 AC 335 ms
5,376 KB
testcase_14 AC 331 ms
5,376 KB
testcase_15 AC 330 ms
5,376 KB
testcase_16 AC 335 ms
6,944 KB
testcase_17 AC 335 ms
5,376 KB
testcase_18 AC 22 ms
5,376 KB
testcase_19 AC 305 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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