結果
問題 |
No.472 平均順位
|
ユーザー |
![]() |
提出日時 | 2018-03-19 13:39:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 369 ms / 2,000 ms |
コード長 | 781 bytes |
コンパイル時間 | 1,587 ms |
コンパイル使用メモリ | 161,336 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-31 10:42:57 |
合計ジャッジ時間 | 4,091 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N, P; cin >> N >> P; vector<int> a(N), b(N), c(N); for(int i = 0; i < N; ++i) cin >> a[i] >> b[i] >> c[i]; vector<int> cur(P+1, INT_MAX); vector<int> nex(P+1, INT_MAX); cur[0] = 0; for(int i = 0; i < N; ++i) { fill(nex.begin(), nex.end(), INT_MAX); for(int j = P; j >= 0; --j) { if(j >= 0 && cur[j-0] != INT_MAX) nex[j] = min(nex[j], cur[j-0]+a[i]); if(j >= 1 && cur[j-1] != INT_MAX) nex[j] = min(nex[j], cur[j-1]+b[i]); if(j >= 2 && cur[j-2] != INT_MAX) nex[j] = min(nex[j], cur[j-2]+c[i]); if(j >= 3 && cur[j-3] != INT_MAX) nex[j] = min(nex[j], cur[j-3]+1); } cur.swap(nex); } cout << fixed << setprecision(12) << (double)cur[P]/N << endl; return 0; }