結果

問題 No.1623 三角形の制作
ユーザー srjywrdnprkt
提出日時 2023-06-11 05:50:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,196 ms / 2,000 ms
コード長 836 bytes
コンパイル時間 1,202 ms
コンパイル使用メモリ 111,300 KB
最終ジャッジ日時 2025-02-14 01:34:09
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    ll N, g, b, ans=0, cnt;
    cin >> N;
    vector<ll> r(N), cb(3e3+1), cg(3e3+1);
    for (int i=0; i<N; i++) cin >> r[i];
    for (int i=0; i<N; i++){
        cin >> g;
        cg[g]++;
    }
    for (int i=0; i<N; i++){
        cin >> b;
        cb[b]++;
    }
    sort(r.begin(), r.end());
    for (int g=1; g<=3e3; g++){
        for (int b=1; b<=3e3; b++){
            cnt = lower_bound(r.begin(), r.end(), g+b)-lower_bound(r.begin(), r.end(), max(g, b));
            ans += cnt * cg[g] * cb[b];
        }
    }

    cout << ans << endl;

    return 0;
}
0