Submission #737745

# Submission time Handle Problem Language Result Execution time Memory
737745 2023-05-07T16:51:12 Z Ariadna Izbori (COCI22_izbori) C++14
0 / 110
3000 ms 524288 KB
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector < int > a(n), aux;
    int t = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        t = max(t, a[i]);
    }
    ll ans = n, ant;
    for (int i = 0; i < n; ++i) {
        aux = vector < int >(t + 1, 0); 
        aux[a[i]] = 1;
        ant = a[i];
        for (int j = i + 1; j < n; ++j) {
            ++aux[a[j]];
            if (aux[a[j]] > aux[ant]) ant = a[j];
            if (aux[ant] > (j - i + 1) / 2) ++ans;
        }
    }
    cout << ans << '\n';
    
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 220 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 220 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3039 ms 1064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 220 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -