結果

問題 No.3252 Constrained Moving
ユーザー elphe
提出日時 2025-09-05 21:29:43
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 631 bytes
コンパイル時間 3,077 ms
コンパイル使用メモリ 278,304 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-05 21:29:55
合計ジャッジ時間 5,128 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

[[nodiscard]] int_fast32_t solve([[maybe_unused]] const uint_fast32_t N, const uint_fast32_t S, const uint_fast32_t T, const uint_fast32_t K, const std::vector<uint_least32_t>& A) noexcept
{
	if (A[S - 1] + A[T - 1] <= K) return 1;
	else if (std::max(A[S - 1], A[T - 1]) + *std::min_element(A.begin(), A.end()) <= K) return 2;
	else return -1;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	
	uint_fast32_t N, S, T, K;
	std::cin >> N >> S >> T >> K;
	std::vector<uint_least32_t> A(N);
	for (auto& a : A) std::cin >> a;

	std::cout << solve(N, S, T, K, A) << '\n';
	return 0;
}
0