Submission #31849143


Source Code Expand

//{{{ #include <bits/stdc++.h>
#ifndef __clang__
#include <bits/stdc++.h>
#endif
using namespace std; //}}}
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n)                                                              \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)                                                                \
    sort(all(c));                                                              \
for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define cauto const auto &
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) {
    return 1LL << x;
}
template <class T>
inline int size(const T &a) {
    return (int)a.size();
}
template <class T>
inline bool chmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T> &v, const char &c) {
    return make_pair(v, c);
}
template <class T>
inline istream &operator>>(istream &is, vector<T> &v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto &x : v)
        is >> x;
    return is;
}
template <class T>
inline ostream &operator<<(ostream &os, const pair<vector<T>, char> &v) {
    bool t = 0;
    for (const T &x : v.first) {
        if (t)
            os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream &operator<<(ostream &os, vector<T> &v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} __before_main;
//}}}TEMPLATE_END

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    vector<lint> cnt(200000+1);
    for(int x: a) {
        cnt[x]++;
    }

    lint l = 0;
    lint r = n;
    lint c = 0;
    lint ans = 0;
    for(int i = 1; i <= 200000; i++) {
        // move
        l += c;
        c = cnt[i];
        r -= c;
        ans += l*c*r;
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task D - Distinct Trio
User eha
Language C++ (GCC 9.2.1)
Score 400
Code Size 2742 Byte
Status AC
Exec Time 26 ms
Memory 5544 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 23
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 7 ms 4668 KiB
random_02.txt AC 19 ms 5388 KiB
random_03.txt AC 5 ms 4584 KiB
random_04.txt AC 19 ms 5508 KiB
random_05.txt AC 3 ms 4572 KiB
random_06.txt AC 7 ms 4756 KiB
random_07.txt AC 4 ms 4708 KiB
random_08.txt AC 11 ms 4668 KiB
random_09.txt AC 5 ms 4664 KiB
random_10.txt AC 14 ms 4968 KiB
random_11.txt AC 3 ms 4540 KiB
random_12.txt AC 11 ms 4584 KiB
random_13.txt AC 4 ms 4704 KiB
random_14.txt AC 10 ms 4952 KiB
random_15.txt AC 4 ms 4756 KiB
random_16.txt AC 16 ms 5236 KiB
random_17.txt AC 22 ms 5544 KiB
random_18.txt AC 4 ms 4752 KiB
random_19.txt AC 26 ms 5400 KiB
random_20.txt AC 4 ms 4712 KiB
sample_01.txt AC 4 ms 4604 KiB
sample_02.txt AC 4 ms 4752 KiB
sample_03.txt AC 6 ms 4668 KiB