結果
問題 | No.808 Kaiten Sushi? |
ユーザー | mtsd |
提出日時 | 2019-03-22 22:10:47 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 281 ms / 2,000 ms |
コード長 | 3,067 bytes |
コンパイル時間 | 1,819 ms |
コンパイル使用メモリ | 92,612 KB |
実行使用メモリ | 13,028 KB |
最終ジャッジ日時 | 2023-10-19 09:31:04 |
合計ジャッジ時間 | 8,073 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 1 ms
4,348 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | AC | 3 ms
4,348 KB |
testcase_08 | AC | 3 ms
4,348 KB |
testcase_09 | AC | 6 ms
4,348 KB |
testcase_10 | AC | 4 ms
4,348 KB |
testcase_11 | AC | 4 ms
4,348 KB |
testcase_12 | AC | 4 ms
4,348 KB |
testcase_13 | AC | 4 ms
4,348 KB |
testcase_14 | AC | 3 ms
4,348 KB |
testcase_15 | AC | 6 ms
4,348 KB |
testcase_16 | AC | 5 ms
4,348 KB |
testcase_17 | AC | 2 ms
4,348 KB |
testcase_18 | AC | 2 ms
4,348 KB |
testcase_19 | AC | 2 ms
4,348 KB |
testcase_20 | AC | 2 ms
4,348 KB |
testcase_21 | AC | 2 ms
4,348 KB |
testcase_22 | AC | 2 ms
4,348 KB |
testcase_23 | AC | 57 ms
7,260 KB |
testcase_24 | AC | 46 ms
6,548 KB |
testcase_25 | AC | 52 ms
7,032 KB |
testcase_26 | AC | 50 ms
6,848 KB |
testcase_27 | AC | 186 ms
11,388 KB |
testcase_28 | AC | 51 ms
6,020 KB |
testcase_29 | AC | 170 ms
10,992 KB |
testcase_30 | AC | 103 ms
8,436 KB |
testcase_31 | AC | 192 ms
11,752 KB |
testcase_32 | AC | 222 ms
12,832 KB |
testcase_33 | AC | 107 ms
8,384 KB |
testcase_34 | AC | 121 ms
9,120 KB |
testcase_35 | AC | 153 ms
10,272 KB |
testcase_36 | AC | 103 ms
8,300 KB |
testcase_37 | AC | 2 ms
4,348 KB |
testcase_38 | AC | 1 ms
4,348 KB |
testcase_39 | AC | 239 ms
12,192 KB |
testcase_40 | AC | 45 ms
5,736 KB |
testcase_41 | AC | 52 ms
5,980 KB |
testcase_42 | AC | 191 ms
10,724 KB |
testcase_43 | AC | 72 ms
6,748 KB |
testcase_44 | AC | 136 ms
9,116 KB |
testcase_45 | AC | 70 ms
6,756 KB |
testcase_46 | AC | 37 ms
5,388 KB |
testcase_47 | AC | 281 ms
13,028 KB |
testcase_48 | AC | 276 ms
13,028 KB |
testcase_49 | AC | 279 ms
13,028 KB |
testcase_50 | AC | 272 ms
13,028 KB |
testcase_51 | AC | 279 ms
13,028 KB |
testcase_52 | AC | 120 ms
10,320 KB |
testcase_53 | AC | 167 ms
12,824 KB |
testcase_54 | AC | 2 ms
4,348 KB |
testcase_55 | AC | 1 ms
4,348 KB |
testcase_56 | AC | 2 ms
4,348 KB |
testcase_57 | AC | 51 ms
6,904 KB |
testcase_58 | AC | 89 ms
8,640 KB |
ソースコード
#include <iostream> #include <vector> #include <string> #include <cmath> #include <algorithm> #include <utility> #include <queue> #include <set> #include <map> #include <deque> #include <iomanip> #include <cstdio> #include <stack> #include <numeric> using namespace std; typedef long long ll; typedef pair<int,int> PII; typedef vector<int> VI; typedef vector<VI> VVI; #define MP make_pair #define PB push_back #define inf 1000000007 #define rep(i,n) for(int i=0;i<(int)(n);++i) vector<vector<pair<int,ll> > > g; int main(){ int n; ll L; cin >> n >> L; set<ll> st,st2; rep(i,n){ ll a; cin >> a; st.insert(a); } rep(i,n){ ll a; cin >> a; st2.insert(a); } ll ans = 0; ll now = 0; bool flag = 0; while(st2.size()>0){ if(!flag){ auto p = st.lower_bound(now); ll next,next2; if(p==st.end()){ next = *st.begin(); }else{ next = *p; } auto q = st2.lower_bound(next); ll goal; if(q==st2.end()){ next2 = *st2.begin(); auto pp = st.lower_bound(next2); if(pp==st.begin()){ pp = st.end(); pp--; goal = *pp; }else{ pp--; goal = *pp; } }else{ next2 = *q; auto pp = st.lower_bound(next2); pp--; goal = *pp; } if(now<goal){ ans += goal-now; }else{ ans += goal+L-now; } st.erase(goal); now = goal; flag = 1; }else{ auto p = st2.lower_bound(now); ll next,next2; if(p==st2.end()){ next = *st2.begin(); }else{ next = *p; } auto q = st.lower_bound(next); ll goal; if(q==st.end()){ next2 = *st.begin(); auto pp = st2.lower_bound(next2); if(pp==st2.begin()){ pp = st2.end(); pp--; goal = *pp; }else{ pp--; goal = *pp; } }else{ next2 = *q; auto pp = st2.lower_bound(next2); pp--; goal = *pp; } if(now<goal){ ans += goal-now; }else{ ans += goal+L-now; } st2.erase(goal); now = goal; flag = 0; } // for(auto x:st){ // cerr << x << " "; // } // cerr << endl; // for(auto x:st2){ // cerr << x << " "; // } // cerr << endl; } cout << ans << endl; return 0; }