#include<bits/stdc++.h>
using namespace std;
int N;
int MOD = 1e9 + 7;
vector<int> tastes;
int main(){
cin >> N;
tastes = vector<int>(N);
for(int i = 0; i < N; ++i) cin >> tastes[i];
long long int ans = 0;
unordered_map<int, int> frequency;
frequency.reserve(N);
int previousWinner = -1;
for(int i = 0; i < N; ++i){
if(i){
frequency[tastes[i]]--;
}
previousWinner = tastes[i];
ans++;
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++;
}
ans = ans%MOD;
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3060 ms |
2096 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |