QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#391974#7880. Streak ManipulationFiatiustitiaWA 0ms3504kbC++201.4kb2024-04-16 23:25:472024-04-16 23:25:47

Judging History

你现在查看的是最新测评结果

  • [2024-04-16 23:25:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3504kb
  • [2024-04-16 23:25:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int f[N][6][2];
void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> cnts0(n + 1);
    string s;
    cin >> s;
    s = '!' + s;
    for (int i = 1; i <= n; i++)
        cnts0[i] = cnts0[i - 1] + (s[i] == '0');
    auto check = [&](int x)
    {
        for (int i = 0; i <= n; i++)
            for (int j = 0; j <= k; j++)
                f[i][j][0] = f[i][j][1] = INT32_MAX / 2;
        f[0][0][0] = 0;
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= k; j++)
            {
                if (i - x >= 0)
                    f[i][j][1] = min(f[i][j][1], f[i - x][j - 1][0] + cnts0[i] - cnts0[i - x]);
                if (s[i] == '0')
                    f[i][j][0] = min(f[i - 1][j][0], f[i - 1][j][1]);
                else
                    f[i][j][0] = f[i - 1][j][0];
            }
        }
        return min(f[n][k][0], f[n][k][1]) <= m;
    };
    int l = 1, r = n, res = -1;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (check(mid))
        {
            res = mid;
            l = mid + 1;
        }
        else
            r = mid - 1;
    }
    cout << res << '\n';
}

int main()
{
#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3504kb

input:

8 3 2
10110110

output:

1

result:

wrong answer 1st numbers differ - expected: '3', found: '1'