Wrong Answer
Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--){
int n;
cin >> n;
string board;
cin >> board;
vector<int> one;
int i = 0;
while (i < n) {
if (board[i] == '1') {
int length = 0;
while (i < n && board[i] == '1') {
length++;
i++;
}
one.push_back(length);
} else {
i++;
}
}
sort(one.rbegin(), one.rend());
int ans = 0;
for (int j = 0; j < one.size(); j += 2) {
ans += one[j];
}
cout <<ans<<endl;
} return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1113 Fliping Game
- Contest
- Brain Booster #7
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-11-05 14:50:06
- Judged At
- 2024-11-05 14:50:06
- Judged By
- Score
- 5
- Total Time
- 25ms
- Peak Memory
- 532.0 KiB