This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int favourite[200005];
int main() {
int n; cin >> n;
int ans = 0;
for (int i = 0; i < n; i++) cin >> favourite[i];
for (int left = 0; left < n; left++) {
for (int right = left; right < n; right++) {
int temp1 = 0; int temp2 = 0;
for (int i = left; i <= right; i++) {
if (favourite[i] == 1) temp1++;
else temp2++;
}
if (2*max(temp1, temp2) > temp1+temp2) ans++;
}
}
cout << ans << endl;
}
# | 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... |