結果

問題 No.472 平均順位
ユーザー Dugong
提出日時 2017-03-16 23:07:59
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 504 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 34,652 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 02:45:38
合計ジャッジ時間 2,302 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d %d",&n,&p);
      |         ~~~~~^~~~~~~~~~~~~~~
main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                 scanf("%d %d %d",&rnk[i][0],&rnk[i][1],&rnk[i][2]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<algorithm>
using namespace std;

const int INF = 1000000000;

int main(){
	int n,p;
	int rnk[5000][4];
	int dp[15001];
	scanf("%d %d",&n,&p);
	for(int i=0;i<n;i++){
		scanf("%d %d %d",&rnk[i][0],&rnk[i][1],&rnk[i][2]);
		rnk[i][3] = 1;
	}
	fill(dp,dp+p,INF);
	dp[p] = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<=p;j++){
			dp[j] += rnk[i][0];
			for(int k=1;k<=3&&j+k<=p;k++){
				dp[j] = min(dp[j],dp[j+k]+rnk[i][k]);
			}
		}
	}
	printf("%.1f\n",(double)dp[0]/n);
	return 0;
}
0