#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, ans = 0;
cin >> n;
int a[n];
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++) {
map<int, int> m;
int mx = 0;
for(int j = i; j < n; j++) {
m[a[j]]++;
if(m[a[j]] > mx) {
mx = m[a[j]];
}
if(mx > (j-i+1)/2) ans++;
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
71 ms |
352 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
56 ms |
204 KB |
Output is correct |
10 |
Correct |
52 ms |
304 KB |
Output is correct |
11 |
Correct |
55 ms |
204 KB |
Output is correct |
12 |
Correct |
53 ms |
304 KB |
Output is correct |
13 |
Correct |
52 ms |
204 KB |
Output is correct |
14 |
Correct |
53 ms |
312 KB |
Output is correct |
15 |
Correct |
52 ms |
204 KB |
Output is correct |
16 |
Correct |
50 ms |
204 KB |
Output is correct |
17 |
Correct |
11 ms |
320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3097 ms |
1228 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
71 ms |
352 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
56 ms |
204 KB |
Output is correct |
10 |
Correct |
52 ms |
304 KB |
Output is correct |
11 |
Correct |
55 ms |
204 KB |
Output is correct |
12 |
Correct |
53 ms |
304 KB |
Output is correct |
13 |
Correct |
52 ms |
204 KB |
Output is correct |
14 |
Correct |
53 ms |
312 KB |
Output is correct |
15 |
Correct |
52 ms |
204 KB |
Output is correct |
16 |
Correct |
50 ms |
204 KB |
Output is correct |
17 |
Correct |
11 ms |
320 KB |
Output is correct |
18 |
Execution timed out |
3097 ms |
1228 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |