結果
問題 |
No.2091 Shio Ramen (Easy)
|
ユーザー |
![]() |
提出日時 | 2022-11-01 13:58:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 423 bytes |
コンパイル時間 | 1,717 ms |
コンパイル使用メモリ | 173,124 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-30 02:27:02 |
合計ジャッジ時間 | 2,309 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N, S, K; cin >> N >> S >> K; typedef pair<int, int> P; vector<P> v; for( int i = 0; i < N; i++ ) { int A; cin >> A; int a = abs( A - S ); if( a > K ) continue; v.push_back( P( a, i + 1 ) ); } if( (int)v.size() == 0 ) { cout << "Unlucky!" << endl; return 0; } sort( v.begin(), v.end() ); int ans = v[0].second; cout << ans << endl; }