Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* BISMILLAHIR-RAHMANIR-RAHIM
- ____________________________________
- | |
- | SHANTO_SUST_SWE-19_029 |
- |____________________________________|
- */
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
- #define pb push_back
- #define Pi acos(-1.0)
- #define r0 return 0
- #define endl "\n"
- #define show(x) cout << x << endl
- #define take(x) cin >> x
- #define debug 1
- int main()
- {
- int t, i, j, tot, point;
- cin >> t;
- string s;
- vector < int > v;
- while(t--) {
- cin >> s;
- int sz = s.size();
- for(i = 0; i < sz; ) {
- if(s[i] == '1') {
- tot = 0;
- for(j = i; j < sz; j++) {
- if(s[j] != '1') break;
- }
- v.push_back(j - i);
- i = j;
- }
- else i++;
- }
- sort(v.rbegin(), v.rend());
- sz = v.size();
- point = 0;
- for(i = 0; i < sz; i += 2) {
- point += v[i];
- }
- cout << point << endl;
- s.clear();
- v.clear();
- }
- r0;
- }
- //ALHAMDULILLAH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement