이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define ull unsigned long long
using namespace std;
const ll mod = 1e9 + 7;
const ll N = 5e5 + 5;
const ll P = 337ll;
ll n,q,k;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
ll a[n];
for(ll i = 0; i<n; i++) {
cin>>a[i];
}
ll ans = 0;
for(ll i = 0; i<n; i++) {
ll maxi = 0;
map <ll,ll> cnt;
for(ll j = i; j<n; j++) {
cnt[a[j]]++;
maxi = max(cnt[a[j]], maxi);
if(maxi > (j - i + 1) / 2) {
//cout<<maxi<<" "<<i<<" "<<j<<" "<<(j - i + 1) / 2<<"\n";
ans++;
}
}
}
cout<<ans;
return 0;
}
// equal, min, max, 1, random
/*
*/
# | 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... |