結果

問題 No.808 Kaiten Sushi?
ユーザー t33ft33f
提出日時 2019-03-25 23:07:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,191 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 65,000 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-17 23:28:30
合計ジャッジ時間 5,493 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 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
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 31 ms
5,376 KB
testcase_24 AC 24 ms
5,376 KB
testcase_25 AC 26 ms
5,376 KB
testcase_26 AC 25 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
testcase_57 AC 23 ms
5,376 KB
testcase_58 AC 41 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main () {
    int n, L; cin >> n >> L;
    int x[n], y[n];
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < n; i++) cin >> y[i];
    int i = 0, j = 0, prev = 0, count = 0, pos = 0;
    long long ans = 0;
    int consecCount[2] = {0, 0};
    while (i < n || j < n) {
        if (j == n) {
            if (prev == 1) count = 0, pos = x[i];
            count += n - i;
            i = n;
        } else if (i == n) {
            if (prev == 0) count = 0, pos = y[j];
            count += n - j;
            j = n;
        } else if (x[i] < y[j]) {
            if (prev == 0) count++;
            else {
                prev = 0;
                count = 1;
                pos = x[i];
            }
            i++;
        } else {
            if (prev == 1) count++;
            else {
                prev = 1; count = 1;
                pos = y[j];
            }
            j++;
        }
        consecCount[prev] = max(consecCount[prev], count);
        int loops = count;
        if (prev == 1 && consecCount[0] < count) loops++;
        ans = max(ans, (long long)(loops - 1) * L + pos);
    }
    cout << ans << endl;
}
0