#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
#define clr(a, x) memset(a, x, sizeof(a))
#define dbg(x) cout<<"("<<#x<<"): "<<x<<endl;
#define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define all(v) v.begin(), v.end()
#define lcm(a, b) (a * b)/__gcd(a, b)
#define int long long int
#define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl;
#define endl '\n'
#define float long double
const int MOD = 1e9 + 7;
const int INF = 2e15;
const int MAXN = 1e5 + 5;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int n;
cin>>n;
int a[n+3];
for(int i=0;i<n;i++){
cin>>a[i];
}
int ans = 0;
for(int i=0;i<n;i++){
for(int j =i;j<n;j++){
map<int, int> x;
int mx = -1;
for(int k = i;k<=j;k++){
x[a[k]]++;
mx = max(mx, x[a[k]]);
}
int len = (j-i+1);
if(mx > (len-mx)){
ans++;
}
}
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
212 KB |
Output is correct |
3 |
Correct |
48 ms |
212 KB |
Output is correct |
4 |
Correct |
52 ms |
300 KB |
Output is correct |
5 |
Correct |
48 ms |
304 KB |
Output is correct |
6 |
Correct |
15 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
212 KB |
Output is correct |
3 |
Correct |
48 ms |
212 KB |
Output is correct |
4 |
Correct |
52 ms |
300 KB |
Output is correct |
5 |
Correct |
48 ms |
304 KB |
Output is correct |
6 |
Correct |
15 ms |
212 KB |
Output is correct |
7 |
Execution timed out |
3069 ms |
356 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3094 ms |
1236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
212 KB |
Output is correct |
3 |
Correct |
48 ms |
212 KB |
Output is correct |
4 |
Correct |
52 ms |
300 KB |
Output is correct |
5 |
Correct |
48 ms |
304 KB |
Output is correct |
6 |
Correct |
15 ms |
212 KB |
Output is correct |
7 |
Execution timed out |
3069 ms |
356 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |