QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#737450#7880. Streak ManipulationyldWA 0ms3616kbC++201.2kb2024-11-12 15:52:152024-11-12 15:52:16

Judging History

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

  • [2024-11-12 15:52:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-11-12 15:52:15]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    string s;cin>>s;
    vector<int> sum(n+1);
    s=' '+s;
    for(int i=1;i<=n;i++)
    {
        sum[i]+=sum[i-1];
        if(s[i]=='0') sum[i]++;
    }
    auto check=[&](int x)
    {
        vector<vector<vector<int>>> dp(n+1,vector<vector<int>>(k+1,vector<int>(2,1e18)));
        dp[0][0][0]=0;
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<=k;j++)
            {
                dp[i][j][0]=min(dp[i-1][j][0],dp[i-1][j][1]);
                if(i>=x && j>=1)
                {
                    dp[i][j][1]=min(dp[i-x][j-1][0]+sum[i]-sum[i-x],dp[i][j][1]);
                }
            }
        }
        if(min(dp[n][k][0],dp[n][k][1])<=m) return 1;
        else return 0;
    };
    int l=0,r=n+1;
    while(l<r)
    {
        int mid=l+r>>1;
        if(check(mid)) l=mid+1;
        else r=mid;
    }
    l--;
    if(l==0) cout<<-1<<endl;
    else cout<<l-1<<endl;
}
signed main()
{
    cin.tie(0)->sync_with_stdio(0);
    int t=1;
    while(t--) solve();
    return 0;
}

詳細信息

Test #1:

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

input:

8 3 2
10110110

output:

2

result:

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