結果

問題 No.808 Kaiten Sushi?
ユーザー sykwer
提出日時 2019-03-22 23:17:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,744 bytes
コンパイル時間 1,321 ms
コンパイル使用メモリ 116,652 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-19 06:54:23
合計ジャッジ時間 5,824 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 5 WA * 18 TLE * 1 -- * 32
権限があれば一括ダウンロードができます

ソースコード

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