Advertisement
rayated

Untitled

Jun 3rd, 2021
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n,k;string s;cin>>n>>k>>s;
  6.     vector<int>a(n+1,0);
  7.     int fas=0,nxt=1,rem=k,x=0;
  8.     for(int i=0;i<n;i++)
  9.     {
  10.         if(s[i]=='+'){a[i-fas+1]++;x=max(x,i-fas+1);}
  11.         else if(k==0){fas=i+1;}
  12.         else if(rem!=0){a[i-fas+1]++;x=max(x,i-fas+1);rem--;nxt=i+1;}
  13.         else if(rem==0){fas=nxt;a[i-fas+1]++;x=max(x,i-fas+1);nxt=i+1;}
  14.     }
  15.     cout<<x<<" "<<a[x]<<endl;
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement