結果

問題 No.2091 Shio Ramen (Easy)
ユーザー roarisroaris
提出日時 2022-10-06 04:52:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 839 bytes
コンパイル時間 4,221 ms
コンパイル使用メモリ 210,880 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 14:06:08
合計ジャッジ時間 3,085 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

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