結果

問題 No.2091 Shio Ramen (Easy)
ユーザー Tatsu_mr
提出日時 2024-09-30 19:02:24
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 2,491 ms
コンパイル使用メモリ 243,384 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-09-30 19:02:33
合計ジャッジ時間 3,184 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, s, k;
    cin >> n >> s >> k;
    int ans = -1, diff = 100;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        int d = abs(a - s);
        if (d <= k && d < diff) {
            ans = i;
            diff = d;
        }
    }
    if (ans >= 1) {
        cout << ans << endl;
    } else {
        cout << "Unlucky!" << endl;
    }
}
0