結果
問題 | No.1742 Binary Indexed Train |
ユーザー |
![]() |
提出日時 | 2025-04-09 21:06:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 192 ms / 3,000 ms |
コード長 | 604 bytes |
コンパイル時間 | 315 ms |
コンパイル使用メモリ | 82,648 KB |
実行使用メモリ | 114,312 KB |
最終ジャッジ日時 | 2025-04-09 21:08:17 |
合計ジャッジ時間 | 6,438 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
import sys def main(): input = sys.stdin.read data = input().split() idx = 0 N = int(data[idx]) Q = int(data[idx + 1]) idx += 2 for _ in range(Q): S = int(data[idx]) T = int(data[idx + 1]) idx += 2 ans = 0 while S < T: if S == 0: lsb_s = (T & -T) else: lsb_s = (S & -S) lsb_t = (T & -T) if lsb_s < lsb_t: S += lsb_s else: T -= lsb_t ans += 1 print(ans) if __name__ == "__main__": main()