結果
問題 | No.814 ジジ抜き |
ユーザー |
|
提出日時 | 2019-04-18 05:05:42 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 675 ms / 3,000 ms |
コード長 | 745 bytes |
コンパイル時間 | 776 ms |
コンパイル使用メモリ | 119,028 KB |
実行使用メモリ | 41,196 KB |
最終ジャッジ日時 | 2024-06-22 00:44:05 |
合計ジャッジ時間 | 13,596 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
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; }