結果
問題 |
No.808 Kaiten Sushi?
|
ユーザー |
![]() |
提出日時 | 2019-03-22 23:47:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,169 bytes |
コンパイル時間 | 586 ms |
コンパイル使用メモリ | 65,888 KB |
実行使用メモリ | 14,592 KB |
最終ジャッジ日時 | 2024-10-12 21:54:08 |
合計ジャッジ時間 | 31,742 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 TLE * 5 |
ソースコード
#include <iostream> #include <algorithm> #include <set> #define int long long #define rep(i, n) for(i = 0; i < n; i++) using namespace std; int n, l; int x[100000]; int y[100000]; int simurate(int last) { set<int> A; set<int> B; set<int>::iterator it; int i; rep(i, n) if (i > 0) A.insert(x[i]); rep(i, n) if (i != last) B.insert(y[i]); int now = x[0]; int ret = 0; rep(i, 2 * n - 2) { if (i % 2 == 0) { it = B.lower_bound(now); if (it == B.end()) it = B.lower_bound(0); int nxt = (*it); if (nxt < now) { ret++; } B.erase(it); now = nxt; } else { it = A.lower_bound(now); if (it == A.end()) it = A.lower_bound(0); int nxt = (*it); if (nxt < now) { ret++; } A.erase(it); now = nxt; } } if (y[last] < now) ret++; return ret; } signed main() { int i; cin >> n >> l; rep(i, n) cin >> x[i]; rep(i, n) cin >> y[i]; int okimoti = simurate(n - 1); int st = -1, ed = n - 1, mid; //(st, ed], xxxooo while (ed - st >= 2) { mid = (st + ed) / 2; if (simurate(mid) > okimoti) st = mid; else ed = mid; } int ans = simurate(ed) * l + y[ed]; cout << ans << endl; return 0; }