結果

問題 No.1623 三角形の制作
ユーザー rogi52rogi52
提出日時 2022-10-06 18:11:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 1,961 ms
コンパイル使用メモリ 197,628 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-01 23:05:37
合計ジャッジ時間 4,090 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
4,380 KB
testcase_01 AC 17 ms
4,380 KB
testcase_02 AC 43 ms
4,376 KB
testcase_03 AC 41 ms
4,376 KB
testcase_04 AC 42 ms
4,376 KB
testcase_05 AC 62 ms
4,376 KB
testcase_06 AC 23 ms
4,380 KB
testcase_07 AC 41 ms
4,376 KB
testcase_08 AC 24 ms
4,376 KB
testcase_09 AC 39 ms
4,376 KB
testcase_10 AC 53 ms
4,376 KB
testcase_11 AC 45 ms
4,376 KB
testcase_12 AC 30 ms
4,376 KB
testcase_13 AC 33 ms
4,380 KB
testcase_14 AC 33 ms
4,376 KB
testcase_15 AC 57 ms
4,380 KB
testcase_16 AC 57 ms
4,380 KB
testcase_17 AC 57 ms
4,376 KB
testcase_18 AC 61 ms
4,380 KB
testcase_19 AC 35 ms
4,384 KB
testcase_20 AC 17 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    int MAX_L = 3000;
    ll R[MAX_L + 1] = {}, G[MAX_L + 1] = {}, B[MAX_L + 1] = {};
    int n; cin >> n;
    rep(_,n) { int x; cin >> x; R[x]++; }
    rep(_,n) { int x; cin >> x; G[x]++; }
    rep(_,n) { int x; cin >> x; B[x]++; }

    ll sumR[MAX_L + 2] = {};
    for(int i = 0; i <= MAX_L; i++) sumR[i + 1] += sumR[i] + R[i];

    // max(g,b) <= r < g+b
    ll ans = 0;
    for(int g = 1; g <= MAX_L; g++) {
        for(int b = 1; b <= MAX_L; b++) {
            ans += (sumR[min(g + b, MAX_L + 1)] - sumR[max(g, b)]) * G[g] * B[b];
        }
    }
    cout << ans << endl;
}
0