結果

問題 No.3795 Circular railway
コンテスト
ユーザー Rino-program
提出日時 2026-11-07 13:27:22
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 151 ms / 2,000 ms
+ 881µs
コード長 254 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 78 ms
コンパイル使用メモリ 64,440 KB
実行使用メモリ 81,260 KB
最終ジャッジ日時 2026-11-13 22:00:43
合計ジャッジ時間 5,259 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, Q, S, T, C = map(int, input().split(" "))
answer = []
def d(X, Y, N=N):
    return (Y - X + N) % N
for _ in range(Q):
    U, V = map(int, input().split(" "))
    ans = min(d(U, V), d(U, S) + C + d(T, V))
    answer.append(ans)
print(*answer, sep="\n")
0