Submission #893751

#TimeUsernameProblemLanguageResultExecution timeMemory
893751vjudge1Izbori (COCI22_izbori)C++17
25 / 110
3065 ms1372 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...