제출 #1300898

#제출 시각아이디문제언어결과실행 시간메모리
1300898hssaan_arifIzbori (COCI22_izbori)C++20
25 / 110
3095 ms1352 KiB
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define pb push_back #define int long long #define fi first #define se second const int N = 3e5 + 5, M = 1e9 + 7, LG = 20; int n , A[N]; void solve(){ cin >> n; for (int i=1 ; i<=n ; i++){ cin >> A[i]; } int ans = 0; for (int i=1 ; i<=n ; i++){ set<pair<int,int>> st; map<int,int> mp; for (int j=i ; j>=1 ; j--){ st.erase({-mp[A[j]] , A[j]}); mp[A[j]]++; st.insert({-mp[A[j]] , A[j]}); if (-(*(st.begin())).fi >= ((i-j+1)/2) + 1){ ans++; } } } cout << ans << endl; } signed main(){ // freopen("" , "r" , stdin); // freopen("" , "w" , stdout); // cout << setprecision(30); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ts = 1; // cin >> ts; while(ts--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...