結果

問題 No.1623 三角形の制作
ユーザー Manuel1024Manuel1024
提出日時 2022-05-16 03:01:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 821 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 76,192 KB
実行使用メモリ 5,552 KB
最終ジャッジ日時 2023-10-11 17:09:55
合計ジャッジ時間 4,736 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 81 ms
4,372 KB
testcase_03 AC 78 ms
4,460 KB
testcase_04 AC 77 ms
4,372 KB
testcase_05 AC 133 ms
5,492 KB
testcase_06 AC 25 ms
4,376 KB
testcase_07 AC 77 ms
4,428 KB
testcase_08 AC 28 ms
4,372 KB
testcase_09 AC 72 ms
4,448 KB
testcase_10 AC 112 ms
4,912 KB
testcase_11 AC 89 ms
4,556 KB
testcase_12 AC 41 ms
4,372 KB
testcase_13 AC 50 ms
4,376 KB
testcase_14 AC 47 ms
4,372 KB
testcase_15 AC 116 ms
5,504 KB
testcase_16 AC 117 ms
5,388 KB
testcase_17 AC 117 ms
5,552 KB
testcase_18 AC 141 ms
5,412 KB
testcase_19 AC 50 ms
4,424 KB
testcase_20 AC 1 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(){
    int n; cin >> n;
    vector<int> r(n), g(n), b(n);
    for(auto &it: r) cin >> it;
    for(auto &it: g) cin >> it;
    for(auto &it: b) cin >> it;

    vector<int> rcnt(3010, 0), gcnt(3010, 0), bcnt(3010, 0);
    for(auto &it: r) rcnt[it]++;
    for(auto &it: g) gcnt[it]++;
    for(auto &it: b) bcnt[it]++;

    vector<int> btot(3020, 0);
    for(int i = 0; i < 3010; i++) btot[i+1] = btot[i]+bcnt[i];
    ll ans = 0;
    for(int i = 1; i < 3010; i++){
        if(rcnt[i] == 0) continue;
        for(int j = 1; j <= i; j++){
            if(gcnt[j] == 0) continue;
            ans += 1LL*rcnt[i]*gcnt[j]*(btot[i+1]-btot[i-j+1]);
        }
    }
    cout << ans << endl;
    return 0;
}
0