結果
問題 |
No.472 平均順位
|
ユーザー |
|
提出日時 | 2017-09-20 17:52:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,293 bytes |
コンパイル時間 | 1,624 ms |
コンパイル使用メモリ | 169,984 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-11-08 09:09:23 |
合計ジャッジ時間 | 5,988 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 4 TLE * 1 -- * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() int main(){ int n,p;cin>>n>>p; vector<vector<int> > data(n,vector<int>(3)); REP(i,n){ REP(j,3){ cin>>data[i][j]; } } vector<vector<int> > memo(n,vector<int>(p+1)); vector<vector<bool> > done(n,vector<bool>(p+1)); function<int (int,int)> func=[=,&func,&done,&memo](int depth,int remain){ cerr<<"Called:"<<depth<<","<<remain<<endl; if(depth==n){ if(remain==0){ cerr<<"Returned 0"<<endl; return 0; }else{ cerr<<"Returned INF"<<endl; return 1<<30; } } if(remain<0){ cerr<<"Not remained"<<endl; return 1<<30; } if(done[depth][remain]==true){ return memo[depth][remain]; } done[depth][remain]=true; int res=1<<30; REP(i,3){ res=min(res,func(depth+1,remain-i)+data[depth][i]); } res=min(res,func(depth+1,remain-3)+1); return memo[depth][remain]=res; }; cout<<fixed<<setprecision(5)<<(double)func(0,p)/n<<endl; return 0; }