比赛 |
EYOI暨SBOI暑假快乐赛6th |
评测结果 |
AAAAATTEEE |
题目名称 |
Count 1s |
最终得分 |
50 |
用户昵称 |
cb |
运行时间 |
2.936 s |
代码语言 |
C++ |
内存使用 |
4.35 MiB |
提交时间 |
2022-06-30 10:38:50 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
bool f[100005] = {0};
int main () {
freopen ("count1s.in", "r", stdin);
freopen ("count1s.out", "w", stdout);
scanf ("%d", &n);
int cnt = 0;
for (int q = 1; q <= n; ++q) {
scanf ("%d", &a[q]);
if (a[q] == 1) cnt ++;
}
f[cnt] = true;
int x0, x1;
for (int q = 1; q <= n; ++q) {
x0 = 0; x1 = 0;
for (int w = q;w <= n; ++w) {
if (a[w] == 0) x0 ++;
else x1 ++;
f[cnt - x1 + x0] = true;
}
}
int ans = 0;
for (int q = 0; q <= n; ++q) {
if (f[q]) ans ++;
}
printf ("%d\n", ans);
return 0;
}