結果
問題 | No.798 コレクション |
ユーザー | ikd |
提出日時 | 2018-08-07 17:20:06 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 796 bytes |
コンパイル時間 | 730 ms |
コンパイル使用メモリ | 77,048 KB |
実行使用メモリ | 8,044 KB |
最終ジャッジ日時 | 2023-09-11 02:24:09 |
合計ジャッジ時間 | 4,623 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,376 KB |
testcase_13 | WA | - |
testcase_14 | TLE | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<functional> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) int main(){ int n; cin>> n; vector<int> a(n), b(n); rep(i, n) cin>> a[i]>> b[i]; const int inf=1e9; vector<int> memo(1<<n, inf); function<int(int)> f=[&](int state)->int{ if(state==0) return 0; if(memo[state]<inf) return memo[state]; int &ret=memo[state]; int cnt=n-__builtin_popcount(state), day=cnt-cnt/3; rep(i, n)if(state&(1<<i)){ auto s=a[i]+b[i]*day, nexstate=state^(1<<i); ret=min(ret, s+f(nexstate)); if(day%2==1){ rep(j, n)if(nexstate&(1<<j)){ ret=min(ret, s+f(nexstate^(1<<j))); } } } return ret; }; cout<< f((1<<n)-1)<< endl; return 0; }