# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
895776 | Isam | Izbori (COCI22_izbori) | C++17 | 3051 ms | 1112 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
constexpr int sz = 500005;
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int N;
cin >> N;
vector<int> A(N);
for(int &a : A) cin >> a;
auto chk = [&](int l, int r){
map<int, int> mp;
for(register int i = l; i <= r; ++i) mp[A[i]]++;
int that(0);
for(auto &toto : mp) that = max(that, toto.second);
return (that << 1) > (r - l + 1);
};
int ans(0);
for(register int i = 0; i < N; ++i){
for(register int j = i; j < N; ++j){
ans += chk(i, j);
}
}
cout << ans << '\n';
/*
2 2 1 2 3
2;
2;
1;
2;
3;
2 2;
2 2 1;
2 1 2;
2 2 1 2;
2 2 1 2 3;
*/
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |