結果
| 問題 |
No.3252 Constrained Moving
|
| コンテスト | |
| ユーザー |
aqua
|
| 提出日時 | 2025-09-05 21:43:59 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 2,000 ms |
| コード長 | 780 bytes |
| コンパイル時間 | 4,138 ms |
| コンパイル使用メモリ | 283,708 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-05 21:44:06 |
| 合計ジャッジ時間 | 6,169 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; }
bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; }
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N, S, T, K; cin >> N >> S >> T >> K; --S, --T;
vector<pair<int,int>> A(N);
for(int i=0; i<N; ++i) {
cin >> A[i].first;
A[i].second = i;
}
sort(A.begin(), A.end());
int s = -1, t = -1;
for(int i=0; i<N && A[0].first + A[i].first <= K; ++i) {
if(A[i].second == S) s = i;
if(A[i].second == T) t = i;
}
if(s == -1 || t == -1) cout << -1 << '\n';
else if(A[s].first + A[t].first <= K) cout << 1 << '\n';
else cout << 2 << '\n';
}
aqua