제출 #526700

#제출 시각아이디문제언어결과실행 시간메모리
526700joelauIzbori (COCI22_izbori)C++14
40 / 110
59 ms14356 KiB
#include <bits/stdc++.h> using namespace std; long long N,A[200005]; map<long long,long long> mp; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> N; for (long long i = 0; i < N; ++i) cin >> A[i]; if (N <= 2000) { long long ans = 0; for (long long i = 0; i < N; ++i) { mp.clear(); long long most = 0; for (long long j = i; j < N; ++j) { most = max(most,++mp[A[j]]); if (most * 2 > j-i+1) ans++; } } cout << ans; } else { long long ans = N * (N+1) / 2, cnt = 0; mp[cnt]++; for (long long i = 0; i < N; ++i) { if (A[i] == 1) cnt--; else cnt++; ans -= mp[cnt]++; } cout << ans; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...