結果

問題 No.1623 三角形の制作
ユーザー erbowlerbowl
提出日時 2022-09-02 07:59:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,247 bytes
コンパイル時間 2,726 ms
コンパイル使用メモリ 206,116 KB
実行使用メモリ 144,384 KB
最終ジャッジ日時 2024-04-27 11:13:13
合計ジャッジ時間 7,029 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
144,384 KB
testcase_01 AC 147 ms
144,256 KB
testcase_02 AC 172 ms
144,256 KB
testcase_03 AC 169 ms
144,256 KB
testcase_04 AC 168 ms
144,256 KB
testcase_05 AC 193 ms
144,256 KB
testcase_06 AC 152 ms
144,128 KB
testcase_07 AC 167 ms
144,256 KB
testcase_08 AC 152 ms
144,256 KB
testcase_09 AC 167 ms
144,384 KB
testcase_10 AC 186 ms
144,384 KB
testcase_11 AC 172 ms
144,256 KB
testcase_12 AC 157 ms
144,256 KB
testcase_13 AC 159 ms
144,384 KB
testcase_14 AC 158 ms
144,256 KB
testcase_15 AC 185 ms
144,256 KB
testcase_16 AC 183 ms
144,256 KB
testcase_17 AC 183 ms
144,256 KB
testcase_18 AC 189 ms
144,256 KB
testcase_19 AC 162 ms
144,256 KB
testcase_20 AC 144 ms
144,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

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

    ll n;
    std::cin >> n;
    vector<ll> cnt1(3001,0),cnt2(3001,0),cnt3(3001,0);
    for (int i = 0; i < n; i++) {
        ll a;
        std::cin >> a;
        cnt1[a]++;
    }
    for (int i = 0; i < n; i++) {
        ll a;
        std::cin >> a;
        cnt2[a]++;
    }
    for (int i = 0; i < n; i++) {
        ll a;
        std::cin >> a;
        cnt3[a]++;
    }
    vector<vector<ll>> dp(6001,vector<ll>(3001));
    for (int i = 1; i <= 6000; i++) {
        for (int j = max((ll)1,i-3000); j <= min(i,(ll)3000); j++) {
            dp[i][max(j,i-j)] += cnt2[i-j]*cnt3[j];
            if(cnt2[i-j]*cnt3[j]){
                // std::cout << i<<" "<<j<<" "<<cnt2[i-j]*cnt3[j] << std::endl;
            }
        }
    }
    vector<ll> ruic(3001);
    for (int i = 1; i <= 3000; i++) {
        ruic[i] = ruic[i-1]+cnt1[i];
    }
    ll ans = 0;
    for (int i = 0; i <= 6000; i++) {
        for (int j = 0; j <= i; j++) {
            ans += max(0ll,(ruic[min((ll)3000,i-1)]-ruic[min((ll)3000,j-1)]))*dp[i][j];
        }
    }
    std::cout << ans << std::endl;
}
0