結果
問題 | No.974 最後の日までに |
ユーザー | milanis48663220 |
提出日時 | 2020-06-11 00:31:26 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,230 bytes |
コンパイル時間 | 913 ms |
コンパイル使用メモリ | 93,356 KB |
実行使用メモリ | 28,120 KB |
最終ジャッジ日時 | 2023-09-06 01:41:45 |
合計ジャッジ時間 | 10,540 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 259 ms
27,944 KB |
testcase_01 | AC | 243 ms
27,876 KB |
testcase_02 | AC | 242 ms
27,944 KB |
testcase_03 | AC | 235 ms
28,120 KB |
testcase_04 | AC | 236 ms
27,972 KB |
testcase_05 | AC | 242 ms
28,016 KB |
testcase_06 | AC | 243 ms
27,876 KB |
testcase_07 | AC | 241 ms
27,964 KB |
testcase_08 | AC | 237 ms
27,932 KB |
testcase_09 | AC | 254 ms
27,932 KB |
testcase_10 | AC | 252 ms
27,940 KB |
testcase_11 | AC | 254 ms
27,988 KB |
testcase_12 | AC | 253 ms
28,120 KB |
testcase_13 | AC | 253 ms
27,916 KB |
testcase_14 | AC | 252 ms
28,120 KB |
testcase_15 | AC | 256 ms
27,920 KB |
testcase_16 | WA | - |
testcase_17 | AC | 47 ms
4,376 KB |
testcase_18 | AC | 47 ms
4,380 KB |
testcase_19 | AC | 47 ms
4,376 KB |
testcase_20 | AC | 49 ms
4,376 KB |
testcase_21 | AC | 49 ms
4,376 KB |
testcase_22 | AC | 47 ms
4,376 KB |
testcase_23 | WA | - |
testcase_24 | AC | 48 ms
4,376 KB |
testcase_25 | AC | 2 ms
4,380 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 291 ms
28,056 KB |
testcase_29 | AC | 2 ms
4,376 KB |
testcase_30 | AC | 68 ms
4,376 KB |
testcase_31 | AC | 2 ms
4,376 KB |
testcase_32 | AC | 1 ms
4,380 KB |
testcase_33 | AC | 176 ms
18,516 KB |
testcase_34 | AC | 310 ms
28,008 KB |
testcase_35 | AC | 1 ms
4,376 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 1 ms
4,376 KB |
testcase_39 | AC | 1 ms
4,376 KB |
testcase_40 | AC | 40 ms
4,376 KB |
testcase_41 | AC | 49 ms
4,376 KB |
testcase_42 | WA | - |
testcase_43 | AC | 108 ms
4,380 KB |
testcase_44 | WA | - |
testcase_45 | AC | 66 ms
4,380 KB |
testcase_46 | AC | 2 ms
4,380 KB |
testcase_47 | AC | 1 ms
4,376 KB |
testcase_48 | AC | 2 ms
4,376 KB |
testcase_49 | AC | 1 ms
4,380 KB |
testcase_50 | AC | 1 ms
4,376 KB |
testcase_51 | AC | 2 ms
4,376 KB |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> using namespace std; typedef long long ll; int W; int M; ll a[52], b[52], c[52]; map<ll, ll> mpl, mpr; vector<int> buf; bool left_half; void dfs(int c1, int c2){ if(c1 == 0 && c2 == 0){ int cur = (left_half ? 0 : M); ll money = 0, likes = 0; for(int i : buf) { if(i == 1){ money += a[cur]; }else{ likes += b[cur+1]; money -= c[cur+1]; } cur += i; } if(left_half) { if(mpl.count(money) > 0){ mpl[money] = max(mpl[money], likes); }else{ mpl[money] = likes; } }else{ if(mpr.count(money) > 0){ mpr[money] = max(mpr[money], likes); }else{ mpr[money] = likes; } } } if(c1 != 0){ buf.push_back(1); dfs(c1-1, c2); buf.pop_back(); } if(c2 != 0){ buf.push_back(2); dfs(c1, c2-1); buf.pop_back(); } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> W; for(int i = 0; i < W; i++) cin >> a[i] >> b[i] >> c[i]; if(W == 1){ cout << 0 << endl; return 0; } M = W/2; left_half = true; for(int i = 0; 2*i <= M; i++){ dfs(M-2*i, i); } left_half = false; for(int i = 0; 2*i <= W-M; i++){ dfs(W-M-2*i, i); } auto p = mpr.end(); ll cur_max = 0; while(true){ p--; cur_max = max(cur_max, p->second); mpr[p->first] = cur_max; if(p == mpr.begin()) break; } ll ans = 0; // for(auto i : mpl) cout << i.first << ':' << i.second << ' '; // cout << endl; // for(auto i : mpr) cout << i.first << ':' << i.second << ' '; // cout << endl; for(auto i : mpl){ ll money = i.first; ll likes = i.second; auto p = mpr.lower_bound(-money); if(p == mpr.end()) continue; ans = max(ans, likes+p->second); } cout << ans << endl; }