結果

問題 No.1623 三角形の制作
ユーザー kai4096_donkai4096_don
提出日時 2021-08-20 21:07:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 936 bytes
コンパイル時間 1,600 ms
コンパイル使用メモリ 168,476 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 03:35:58
合計ジャッジ時間 4,762 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
5,248 KB
testcase_01 AC 8 ms
5,376 KB
testcase_02 AC 83 ms
5,376 KB
testcase_03 AC 79 ms
5,376 KB
testcase_04 AC 79 ms
5,376 KB
testcase_05 AC 137 ms
5,376 KB
testcase_06 AC 26 ms
5,376 KB
testcase_07 AC 77 ms
5,376 KB
testcase_08 AC 28 ms
5,376 KB
testcase_09 AC 74 ms
5,376 KB
testcase_10 AC 112 ms
5,376 KB
testcase_11 AC 90 ms
5,376 KB
testcase_12 AC 47 ms
5,376 KB
testcase_13 AC 54 ms
5,376 KB
testcase_14 AC 54 ms
5,376 KB
testcase_15 AC 122 ms
5,376 KB
testcase_16 AC 121 ms
5,376 KB
testcase_17 AC 120 ms
5,376 KB
testcase_18 AC 143 ms
5,376 KB
testcase_19 AC 56 ms
5,376 KB
testcase_20 AC 8 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//const long nPrime = 1000000007;
//const long nPrime = 998244353;
int main() {
    long n;
    cin >> n;
    vector<vector<long>> vviCount(3,vector<long>(4000,0));
    for(long i = 0; i < n; i++){
        long a;
        cin >> a;
        vviCount[0][a]++;
    }
    for(long i = 0; i < n; i++){
        long a;
        cin >> a;
        vviCount[1][a]++;
    }
    for(long i = 0; i < n; i++){
        long a;
        cin >> a;
        vviCount[2][a]++;
    }
    
    vector<long> viSum(4001,0);
    for(long i = 0; i < 4000; i++){
        viSum[i+1] = viSum[i] + vviCount[2][i];
    }
    
    long nAns = 0;
    for(long i = 1; i < 4000; i++){
        for(long j = 1; j <= i; j++){
            long nMin = abs(i-j)+1;
            long nMax = i;
            nAns += vviCount[0][i] * vviCount[1][j] * (viSum[nMax+1]-viSum[nMin]);
        }
    }
    cout << nAns << endl;
    return 0;
}
0