QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#276782 | #7880. Streak Manipulation | 117023 | WA | 4ms | 8628kb | C++17 | 968b | 2023-12-06 10:43:12 | 2023-12-06 10:43:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
string s;
vector<int>sum(100010);
bool check(int mid){
vector<vector<int>>dp(k+10,vector<int>(100010,0x3f3f3f3f));
vector<int>M(k+10,0x3f3f3f3f);
M[0]=0;
dp[0][0]=0;
for(int i=mid;i<s.size();i++){
//if(s[i]!='0')
for(int j=1;j<=k;j++){
if(s[i]=='0') dp[j][i]=M[j-1]+sum[i]-sum[i-mid];
M[j-1]=min(M[j-1],dp[j-1][i-mid]);
// cout<<i<<" "<<j<<" "<<dp[j][i]<<" \n"[j==k-1];
}
}
for(int i=0;i<s.size();i++){
if(dp[k][i]<=m)
return 1;
}
return 0;
}
int main() {
cin>>n>>m>>k;
cin>>s;
//s='0'+s;
s+='0';
for(int i=0;i<s.size();i++){
//if(i!=1) sum[i]+=;
sum[i+1]=-(s[i]-'1')+sum[i];
}
int l=0,r=1e5+10;
while(l<r){
int mid=l+(r-l)/2;
if(check(mid)){
l=mid+1;
}else{
r=mid;
}
cout<<l<<" "<<r<<endl;
}
if(l-1<=0)cout<<-1<<endl;
else cout<<l-1<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 8628kb
input:
8 3 2 10110110
output:
0 50005 0 25002 0 12501 0 6250 0 3125 0 1562 0 781 0 390 0 195 0 97 0 48 0 24 0 12 0 6 4 6 4 5 4 4 3
result:
wrong answer 1st numbers differ - expected: '3', found: '0'