結果

問題 No.2517 Right Triangles on Circle
ユーザー MasKoaTSMasKoaTS
提出日時 2023-08-26 17:08:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 203,656 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 17:08:55
合計ジャッジ時間 5,481 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 135 ms
4,376 KB
testcase_14 AC 100 ms
4,376 KB
testcase_15 AC 147 ms
4,376 KB
testcase_16 AC 145 ms
4,380 KB
testcase_17 AC 103 ms
4,380 KB
testcase_18 AC 99 ms
4,376 KB
testcase_19 AC 89 ms
4,376 KB
testcase_20 AC 89 ms
4,380 KB
testcase_21 AC 130 ms
4,376 KB
testcase_22 AC 35 ms
4,376 KB
testcase_23 AC 106 ms
4,380 KB
testcase_24 AC 48 ms
4,376 KB
testcase_25 AC 29 ms
4,376 KB
testcase_26 AC 123 ms
4,376 KB
testcase_27 AC 33 ms
4,376 KB
testcase_28 AC 21 ms
4,380 KB
testcase_29 AC 47 ms
4,380 KB
testcase_30 AC 28 ms
4,380 KB
testcase_31 AC 106 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

bool bin_search(vector<int>& a, int x){
    int ok = 0;
    int ng = a.size();
    while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if(a[mid] <= x){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    return (a[ok] == x);
}

int main(){
    int n, m;   cin >> n >> m;
    vector<int> a(n);
    for(auto& x : a){
        cin >> x;
    }
    sort(a.begin(), a.end());

    if(m & 1){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    for(auto& x : a){
        if(!bin_search(a, x + m / 2)){
            continue;
        }
        ans += n - 2;
    }
    cout << ans << endl;

    return 0;
}
0