結果

問題 No.814 ジジ抜き
ユーザー nebukuro09nebukuro09
提出日時 2019-04-18 05:05:42
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 652 ms / 3,000 ms
コード長 745 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 106,532 KB
実行使用メモリ 41,448 KB
最終ジャッジ日時 2023-09-04 00:37:45
合計ジャッジ時間 13,908 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 649 ms
41,448 KB
testcase_05 AC 650 ms
40,092 KB
testcase_06 AC 652 ms
39,928 KB
testcase_07 AC 253 ms
23,980 KB
testcase_08 AC 461 ms
39,808 KB
testcase_09 AC 467 ms
25,472 KB
testcase_10 AC 633 ms
39,800 KB
testcase_11 AC 637 ms
39,784 KB
testcase_12 AC 292 ms
23,276 KB
testcase_13 AC 289 ms
23,496 KB
testcase_14 AC 445 ms
27,884 KB
testcase_15 AC 227 ms
15,672 KB
testcase_16 AC 184 ms
15,664 KB
testcase_17 AC 509 ms
30,804 KB
testcase_18 AC 416 ms
24,752 KB
testcase_19 AC 523 ms
39,700 KB
testcase_20 AC 311 ms
23,540 KB
testcase_21 AC 290 ms
24,348 KB
testcase_22 AC 392 ms
32,000 KB
testcase_23 AC 224 ms
17,836 KB
testcase_24 AC 363 ms
25,596 KB
testcase_25 AC 274 ms
24,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto N = readln.chomp.to!int;
    auto KLD = N.iota.map!(_ => readln.split.map!(to!long).array).array;

    bool check(long x) {
        long cnt = 0;
        foreach (kld; KLD) {
            auto k = kld[0], l = kld[1], d = kld[2];
            if (x < l) continue;
            cnt ^= min(k, (x - l) / (1L << d) + 1) & 1;
        }
        return cnt & 1;
    }

    long hi = 10L ^^ 18;
    long lo = -1;

    while (hi - lo > 1) {
        long mid = (hi + lo) / 2;
        (check(mid) ? hi : lo) = mid;
    }

    hi.writeln;
}
0