結果

問題 No.808 Kaiten Sushi?
ユーザー sykwersykwer
提出日時 2019-03-22 23:17:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,744 bytes
コンパイル時間 1,211 ms
コンパイル使用メモリ 117,664 KB
実行使用メモリ 9,864 KB
最終ジャッジ日時 2023-10-19 10:43:54
合計ジャッジ時間 5,947 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 12 ms
4,348 KB
testcase_08 AC 16 ms
4,348 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 3 ms
4,348 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, L;
    cin >> N >> L;

    vector<int> sushis(N);
    set<int> tea_set;
    for (int i = 0; i < N; i++) cin >> sushis[i];
    for (int i = 0; i < N; i++) {
        int y;
        cin >> y;
        tea_set.insert(y);
    }

    int circle_num = 0;
    int last_sushi_pos = sushis[0];
    for (int i = 1; i < N; i++) {
        auto it = lower_bound(tea_set.begin(), tea_set.end(), sushis[i]);

        if (it == tea_set.begin()) {
            it = tea_set.end();
            it--;
            tea_set.erase(it);
            circle_num++;
        } else {
            it--;
            if (*it > last_sushi_pos) {
                tea_set.erase(it);
            } else {
                tea_set.erase(it);
                circle_num++;
            }
        }
        last_sushi_pos = sushis[i];
    }

    int last_pos = *tea_set.begin();
    cout << circle_num * L + last_pos << endl;

    return 0;
}
0