結果

問題 No.3795 Circular railway
ユーザー 👑 loop0919
提出日時 2026-11-13 22:37:13
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 596 ms / 2,000 ms
+ 696µs
コード長 231 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 80 ms
コンパイル使用メモリ 64,256 KB
実行使用メモリ 60,544 KB
最終ジャッジ日時 2026-11-13 22:37:33
合計ジャッジ時間 7,664 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, Q, S, T, C = [int(s) for s in input().split()]
S -= 1
T -= 1


def dist(s, t):
    return (t - s) % N


for _ in range(Q):
    U, V = [int(s) - 1 for s in input().split()]
    print(min(dist(U, V), dist(U, S) + C + dist(T, V)))
0