結果
問題 | No.472 平均順位 |
ユーザー |
|
提出日時 | 2018-09-23 12:14:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 153 ms / 2,000 ms |
コード長 | 827 bytes |
コンパイル時間 | 496 ms |
コンパイル使用メモリ | 65,852 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-13 19:53:13 |
合計ジャッジ時間 | 1,798 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include<iostream>#include <iomanip>#include<algorithm>#define MAX_P 15010#define INF (long long)1e13int main(){std::cout<<std::fixed<<std::setprecision(6);long long dp[2][MAX_P];int N, P, a, b, c;std::cin>>N>>P;for(int j = 0; j <= P; j++)dp[0][j]=dp[1][j]=INF;dp[1][0] = 0;for(int i = 0; i < N; i++){std::cin>>a>>b>>c;for(int j = 0; j <= P; j++){if(dp[(i+1)%2][j] == INF) continue;dp[i%2][j] = std::min(dp[(i+1)%2][j]+a,dp[i%2][j] );dp[i%2][j+1] = std::min(dp[(i+1)%2][j]+b,dp[i%2][j+1]);dp[i%2][j+2] = std::min(dp[(i+1)%2][j]+c,dp[i%2][j+2]);dp[i%2][j+3] = std::min(dp[(i+1)%2][j]+1,dp[i%2][j+3]);dp[(i+1)%2][j] = INF;}// for(int j = 0; j <= P; j++)std::cout<<j<<" "<<dp[i%2][j]<<std::endl;}std::cout<<(double)dp[(N-1)%2][P]/N<<std::endl;return 0;}