Submission #737742

#TimeUsernameProblemLanguageResultExecution timeMemory
737742a_aguiloIzbori (COCI22_izbori)C++14
25 / 110
3071 ms1968 KiB
#include<bits/stdc++.h> using namespace std; int N; int MOD = 1e9 + 7; vector<int> tastes; int main(){ cin >> N; tastes = vector<int>(N); unordered_map<int, int> frequency; frequency.reserve(N); for(int i = 0; i < N; ++i) { cin >> tastes[i]; frequency[tastes[i]] = 0; } long long int ans = 0; int previousWinner = -1; for(int i = 0; i < N; ++i){ previousWinner = tastes[i]; ans++; frequency[tastes[i]]++; for(int j = i+1; j < N; ++j){ frequency[tastes[j]]++; if(frequency[tastes[j]] > frequency[previousWinner])previousWinner = tastes[j]; int dist = j - i +1; if(2*frequency[previousWinner] > dist) ans++; } for(int i = 0; i < N; ++i) frequency[tastes[i]] = 0; ans = ans%MOD; } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...