結果

問題 No.602 隠されていたゲーム2
ユーザー tinumukiti631tinumukiti631
提出日時 2017-12-02 17:26:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 1,228 ms
コンパイル使用メモリ 160,380 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 01:45:56
合計ジャッジ時間 2,221 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 8 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 36 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 35 ms
5,376 KB
testcase_21 AC 26 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 39 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    int N;
    int D[100005];
    int distance;
    int ans = 3;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> D[i];
    sort(D, D + N);
    { int a, b; cin >> a >> b; distance = abs(a) + abs(b); }
    int j = N - 1;
    for(int i = 0; i < N; i++) {
        if(D[i] == distance) ans = min(ans, 1);
        while(j > 0 && D[i] + D[j] > distance) j--;
        if(D[i] + D[j] == distance) ans = min(ans, 2);
    }
    if(ans == 3) cout << -1 << endl;
    else cout << ans << endl;

    return (0);
}
0