結果

問題 No.1623 三角形の制作
ユーザー sten_sansten_san
提出日時 2021-07-23 21:41:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,708 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 202,736 KB
実行使用メモリ 5,592 KB
最終ジャッジ日時 2023-09-25 21:34:43
合計ジャッジ時間 4,800 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
4,380 KB
testcase_01 AC 32 ms
4,380 KB
testcase_02 AC 59 ms
4,380 KB
testcase_03 AC 58 ms
4,380 KB
testcase_04 AC 58 ms
4,380 KB
testcase_05 AC 78 ms
5,420 KB
testcase_06 AC 39 ms
4,376 KB
testcase_07 AC 58 ms
4,384 KB
testcase_08 AC 39 ms
4,376 KB
testcase_09 AC 56 ms
4,508 KB
testcase_10 AC 71 ms
5,108 KB
testcase_11 AC 63 ms
4,768 KB
testcase_12 AC 47 ms
4,380 KB
testcase_13 AC 50 ms
4,376 KB
testcase_14 AC 49 ms
4,380 KB
testcase_15 AC 74 ms
5,588 KB
testcase_16 AC 74 ms
5,384 KB
testcase_17 AC 74 ms
5,592 KB
testcase_18 AC 78 ms
5,372 KB
testcase_19 AC 52 ms
4,656 KB
testcase_20 AC 32 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct iofast_t {
    iofast_t() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} iofast;

struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
    if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
    else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
    return vec(Element(), arg, args...);
}

template <typename T, typename Compare = less<T>>
T &chmin(T &l, T r, Compare &&f = less<T>()) { return l = min(l, r, f); }
template <typename T, typename Compare = less<T>>
T &chmax(T &l, T r, Compare &&f = less<T>()) { return l = max(l, r, f); }

int main() {
    constexpr int lim = 3000;

    int n; cin >> n;
    auto r = vec<int>(uns, n);
    auto g = vec<int>(uns, n);
    auto b = vec<int>(uns, n);
    for (auto &e : r) cin >> e;
    for (auto &e : g) cin >> e;
    for (auto &e : b) cin >> e;

    auto count1 = vec<int64_t>(0, lim + 1);
    auto count2 = vec<int64_t>(0, lim + 1);
    for (auto v : g) {
        ++count1[v];
    }
    for (auto v : b) {
        ++count2[v];
    }

    auto imos = vec<int64_t>(0, lim + 2);
    for (int i = 0; i <= lim; ++i) {
        for (int j = 0; j <= lim; ++j) {
            imos[min(lim + 1, max(i, j))] += count1[i] * count2[j];
            imos[min(lim + 1, i + j)] -= count1[i] * count2[j];
        }
    }

    for (int i = 1; i <= lim; ++i) {
        imos[i] += imos[i - 1];
    }

    int64_t ans = 0;
    for (auto v : r) {
        ans += imos[v];
    }

    cout << ans << endl;
}

0