Advertisement
silentkiler029

cf-1398-B

Aug 14th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. /*    BISMILLAHIR-RAHMANIR-RAHIM
  2.  ____________________________________
  3. |                                    |
  4. |       SHANTO_SUST_SWE-19_029       |
  5. |____________________________________|
  6. */
  7.  
  8. #include <bits/stdc++.h>
  9.  
  10. using namespace std;
  11.  
  12. #define ll          long long
  13. #define fastio      ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  14. #define pb          push_back
  15. #define Pi          acos(-1.0)
  16. #define r0          return 0
  17. #define endl        "\n"
  18. #define show(x)     cout << x << endl
  19. #define take(x)     cin >> x
  20. #define debug       1
  21.  
  22. int main()
  23. {
  24.     int t, i, j, tot, point;
  25.     cin >> t;
  26.     string s;
  27.     vector < int > v;
  28.  
  29.     while(t--) {
  30.         cin >> s;
  31.         int sz = s.size();
  32.  
  33.         for(i = 0; i < sz; ) {
  34.             if(s[i] == '1') {
  35.                 tot = 0;
  36.                 for(j = i; j < sz; j++) {
  37.                     if(s[j] != '1') break;
  38.                 }
  39.                 v.push_back(j - i);
  40.                 i = j;
  41.             }
  42.             else i++;
  43.         }
  44.         sort(v.rbegin(), v.rend());
  45.  
  46.         sz = v.size();
  47.         point = 0;
  48.         for(i = 0; i < sz; i += 2) {
  49.             point += v[i];
  50.         }
  51.  
  52.         cout << point << endl;
  53.  
  54.         s.clear();
  55.         v.clear();
  56.     }
  57.  
  58.     r0;
  59. }
  60.  
  61. //ALHAMDULILLAH
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement