Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- #define loop(i,b,e) for(auto i=b;i<=e;i++)
- #define ALL(x) x.begin(),x.end()
- #define SZ(x) x.size()
- #define PB push_back
- typedef vector<int> VI;
- int n,a,b,cnt,x,ans;
- string s;
- VI v;
- int main() {_
- cin >> n >> a >> b >> s;
- loop(i,0,s.length()) {
- if(s[i] == '.')
- cnt++;
- else if(cnt != 0) {
- v.PB(cnt);
- cnt = 0;
- }
- }
- sort(ALL(v),greater<int>());
- loop(i,0,SZ(v)-1) {
- if(a == 0 && b == 0)
- break;
- if(v[i] % 2 == 0) {
- x = min(v[i]/2,a);
- ans += x;
- a -= x;
- x = min(v[i]/2,b);
- ans += x;
- b -= x;
- }
- else {
- x = min(v[i]/2,b);
- ans += x;
- a -= x;
- x = min(v[i]/2,a);
- ans += x;
- b -= x;
- if(a > b && a >= 1)
- ans++,a--;
- else if(b > a && b >= 1)
- ans++,b--;
- else if(a >= 1 && b >= 1)
- ans++,a--;
- }
- }
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement