Submission #684970

# Submission time Handle Problem Language Result Execution time Memory
684970 2023-01-23T03:29:16 Z moonhero Diversity (CEOI21_diversity) C++14
0 / 100
1 ms 224 KB
#include<bits/stdc++.h>
using namespace std;
const long long N = 1e1 + 5;
long long t[N][N * 4], a[N];
vector <long long> res;
long long cont (long long r) {
    return (r + 1) * (r) / 2;
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, q; cin >> n >> q;
    map <int, int> ans;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        ans[a[i]]++;
    }
    while (q--) {
        int l, r; cin >> l >> r;
        for (auto it : ans) res.push_back(it.second);
        long long x = 0;
        for (int i = 0; i < res.size(); i++) {
            long long nw = 0, k = 2, nwres = res[i];
            for (int j = i + 1; j < res.size(); j++) {
                nw += k, nwres += k * res[j], k++;
            } x += nwres * res[i] - cont(res[i] - 1);
        } cout << x << '\n';
    }
    return 0;
}

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int i = 0; i < res.size(); i++) {
      |                         ~~^~~~~~~~~~~~
diversity.cpp:24:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             for (int j = i + 1; j < res.size(); j++) {
      |                                 ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 224 KB Output is correct
2 Correct 0 ms 224 KB Output is correct
3 Incorrect 1 ms 224 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 224 KB Output is correct
2 Correct 0 ms 224 KB Output is correct
3 Incorrect 1 ms 224 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 224 KB Output is correct
2 Correct 0 ms 224 KB Output is correct
3 Incorrect 1 ms 224 KB Output isn't correct
4 Halted 0 ms 0 KB -