結果

問題 No.2091 Shio Ramen (Easy)
ユーザー roaris
提出日時 2022-10-06 04:52:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 839 bytes
コンパイル時間 2,143 ms
コンパイル使用メモリ 206,416 KB
最終ジャッジ日時 2025-02-07 22:09:52
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
typedef long long ll;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll N, S, K; cin >> N >> S >> K;
    ll A[N]; rep(i, N) cin >> A[i];
    
    map<ll, int> idx;
    vector<ll> v;
    rep(i, N) {
        if (idx.find(A[i])==idx.end()) {
            idx[A[i]] = i;
            v.push_back(A[i]);
        }
    }
    v.push_back(-2e18);
    v.push_back(2e18);
    sort(v.begin(), v.end());
    
    auto it = lower_bound(v.begin(), v.end(), S);
    ll r = *it;
    ll l = *--it;
    ll d = min(S-l, r-S);
    if (d>K) cout << "Unlucky!" << endl;
    else {
        if (l==r) cout << min(idx[l], idx[r])+1 << endl;
        else if (l==d) cout << idx[l]+1 << endl;
        else cout << idx[r]+1 << endl;
    }
}
0