#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
const int N = (int)2e5 + 5;
const ll mod = (int)1e9 + 7;
const ll inf = (int)(1e9) + 100;
map<int, int> ma;
int cnt[N];
void solve() {
int n;
cin >> n;
int a[n + 1];
vector<int> v;
for (int i = 1; i <= n; i++) {
cin >> a[i];
v.pb(a[i]);
}
sort(all(v));
v.erase(unique(all(v)), v.end());
int timer = 0;
for (auto i : v) {
ma[i] = ++timer;
}
for (int i = 1; i <= n; i++) a[i] = ma[a[i]];
if (n <= 300) {
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = i; j <= n; j++) {
bool g = 0;
for (int k = i; k <= j; k++) {
cnt[a[k]]++;
if (cnt[a[k]] >= n / 2 + 1) {
g = 1;
break;
}
}
for (int k = i; k <= j; k++) cnt[a[k]] = 0;
ans += g;
}
}
cout << ans;
return;
}
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T = 1;
//cin >> T;
while (T--) solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
2012 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |