結果
| 問題 | No.3795 Circular railway |
| ユーザー |
|
| 提出日時 | 2026-11-13 23:37:38 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 416 ms / 2,000 ms |
| + 365µs | |
| コード長 | 589 bytes |
| 記録 | |
| コンパイル時間 | 1,667 ms |
| コンパイル使用メモリ | 212,980 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-11-13 23:37:46 |
| 合計ジャッジ時間 | 6,605 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
int main(void){
cin.tie(nullptr); ios_base::sync_with_stdio(false);
ll i,j;
ll N,Q,S,T,C;
cin >> N >> Q >> S >> T >> C;
while(Q--){
ll U,V;
cin >> U >> V;
ll d=-1;
if(U<=V){
d=V-U;
if(U<=S && T<=V) d=min(d,S-U+V-T+C);
}
else{
d=V+N-U;
ll x;
if(S-U<0) x=S+N-U;
else x=S-U;
ll y;
if(V-T<0) y=V+N-T;
else y=V-T;
d=min(d,x+y+C);
}
cout << d << endl;
}
return 0;
}