This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# pragma GCC optimize("O3,unroll-loops")
# pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
# include <bits/stdc++.h>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
# define mkp make_pair
# define ff first
# define ss second
# define pll pair <ll, ll>
# define pii pair <int, int>
# define vec vector
# define pb push_back
# define pf push_front
# define ppb pop_back
# define ppf pop_front
# define all(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
# define sz(x) ((int)(x).size())
# define lb lower_bound
# define ub upper_bound
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
# define br break
# define rt return
# define cn continue
# define nl "\n"
# define off exit(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll MAXN = 1e6 + 25;
const ll MAXL = 18 + 0;
const ll INF1 = 1e18 + 0;
const ll INF2 = 2e9 + 0;
const ll MOD = 1e9 + 7;
const ll M0D = 998244353;
const ld PI = acos((ld) -1);
const ll P = 67 + 0 + 0;
using namespace std;
using namespace __gnu_pbds;
void ma1n ()
{
ll n, ans = 0;
cin >> n;
ll a[n + 3];
for (ll i = 1; i <= n; ++i)
{
cin >> a[i];
}
for (ll i = 1; i <= n; ++i)
{
for (ll j = i; j <= n; ++j)
{
map <int, int> m;
for (ll k = i; k <= j; ++k)
{
m[a[k]]++;
}
ll mx = 0;
for (auto it : m)
{
mx = max(mx, (ll)it.ss);
}
if (mx > (j - i + 1) / 2) ans++;
}
}
cout << ans << nl;
}
int main (/*?*/)
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cerr.tie(0);
// freopen ("file.in", "r", stdin);
// freopen ("file.out", "w", stdout);
int zxc = 1;
// cin >> zxc;
while (zxc--)
{
ma1n();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |