結果

問題 No.2517 Right Triangles on Circle
ユーザー MasKoaTS
提出日時 2023-08-26 17:08:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 2,278 ms
コンパイル使用メモリ 197,824 KB
最終ジャッジ日時 2025-02-16 14:41:59
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

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