#include <iostream>
#include <vector>
#include <map>
using namespace std;
// SUBTASK 2 GRABBING ATTEMPT
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int nums; cin >> nums;
vector<int> vec(nums);
for (int i = 0; i < nums; i++) cin >> vec[i];
int cnt = 0;
for (int i = 0; i < nums; i++) {
map<int, int> m;
int maxval = -1;
for (int j = i; j < nums; j++) {
m[vec[j]]++;
if (m[vec[j]] > m[maxval]) maxval = vec[j];
if (2 * m[maxval] > j - i + 1) cnt++;
}
}
cout << cnt;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
76 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
75 ms |
308 KB |
Output is correct |
10 |
Correct |
75 ms |
300 KB |
Output is correct |
11 |
Correct |
80 ms |
312 KB |
Output is correct |
12 |
Correct |
84 ms |
308 KB |
Output is correct |
13 |
Correct |
75 ms |
204 KB |
Output is correct |
14 |
Correct |
73 ms |
304 KB |
Output is correct |
15 |
Correct |
77 ms |
304 KB |
Output is correct |
16 |
Correct |
73 ms |
308 KB |
Output is correct |
17 |
Correct |
33 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3079 ms |
844 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 |
312 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
76 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
75 ms |
308 KB |
Output is correct |
10 |
Correct |
75 ms |
300 KB |
Output is correct |
11 |
Correct |
80 ms |
312 KB |
Output is correct |
12 |
Correct |
84 ms |
308 KB |
Output is correct |
13 |
Correct |
75 ms |
204 KB |
Output is correct |
14 |
Correct |
73 ms |
304 KB |
Output is correct |
15 |
Correct |
77 ms |
304 KB |
Output is correct |
16 |
Correct |
73 ms |
308 KB |
Output is correct |
17 |
Correct |
33 ms |
204 KB |
Output is correct |
18 |
Execution timed out |
3079 ms |
844 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |