제출 #696924

#제출 시각아이디문제언어결과실행 시간메모리
696924tamthegodIzbori (COCI22_izbori)C++17
25 / 110
3064 ms9292 KiB
// Make the best become better // No room for laziness #include<bits/stdc++.h> #define int long long #define pb push_back #define fi first #define se second using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxN = 2e5 + 5; const int mod = 1e9 + 7; const ll oo = 1e18; int n, a[maxN]; vector<int> pos[maxN]; const int block_size = 2000; void ReadInput() { cin >> n; vector<int> vc; for(int i=1; i<=n; i++) { cin >> a[i]; vc.pb(a[i]); } sort(vc.begin(), vc.end()); vc.erase(unique(vc.begin(), vc.end()), vc.end()); for(int i=1; i<=n; i++) a[i] = upper_bound(vc.begin(), vc.end(), a[i]) - vc.begin(); for(int i=1; i<=n; i++) pos[a[i]].pb(i); } void Solve() { int res = 0; for(int i=1; i<=n; i++) { map<int, int> mp; int _max = 0; for(int j=i; j<=n; j++) { mp[a[j]]++; _max = max(_max, mp[a[j]]); if(_max > (j - i + 1) / 2) res++; } } cout << res; } int32_t main() { //freopen("sol.inp", "r", stdin); //freopen("sol.ans", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(nullptr); ReadInput(); Solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...