QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#307989 | #7880. Streak Manipulation | confesser | WA | 26ms | 8360kb | C++17 | 1.0kb | 2024-01-19 12:29:01 | 2024-01-19 12:29:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using pi=pair<int,int>;
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define G(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(a,b) memset(a,b,sizeof(a))
#define si(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define pb push_back
const int N=2e5+3;
int a[N],dp[N][6];
int main(){
cin.tie(0)->ios::sync_with_stdio(0);
int n,m,d;
cin>>n>>m>>d;
F(i,1,n){
char c;
cin>>c;
a[i]=c-'0';
}
int l=1,r=n,ans=-1;
while(l<=r){
int mid=(l+r)>>1;
auto chk=[&](){
ms(dp,63);
F(i,0,n) dp[i][0]=0;
F(i,1,n) F(j,1,d){
int w=0;
G(k,i,1){
if(!a[k]) w++;
if(i-k+1>=mid&&!a[k-1]){
if(k>=2) dp[i][j]=min(dp[i][j],dp[k-2][j-1]+w);
else if(j==1) dp[i][j]=min(dp[i][j],w);
}
}
}
F(i,1,n) if(dp[i][d]<=m) return 1;
return 0;
};
if(chk()){
ans=mid;
l=mid+1;
}else r=mid-1;
}
cout<<ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 8360kb
input:
8 3 2 10110110
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 3ms
memory: 8304kb
input:
12 3 3 100100010011
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 2ms
memory: 8312kb
input:
4 4 4 0000
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: -100
Wrong Answer
time: 26ms
memory: 8308kb
input:
1000 200 5 0001001000101001110010011001101010110101101100010100111110111111010010001100100111100101011100011101011001110010111100100100011001010011000100011111010110100001101110101001110000001000111010000111110100111101100110011010011111000111101001010011000111010111010100101111100000100001011001010...
output:
90
result:
wrong answer 1st numbers differ - expected: '99', found: '90'