This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int inf = 1e7 + 42;
int main()
{
int N;
cin >> N;
string inp;
cin >> inp;
vector<int> ees;
bool curry = 0;
for (int i = 1; i < N; ++i) {
if (inp[i] == 'e') {
curry = true;
} else if (inp[i] != 'e' && curry) {
ees.push_back(i);
curry = false;
}
}
int ans = 0;
reverse(ees.begin(), ees.end());
int cp = inf;
for (auto &x : ees) {
int cost = min(1, cp - x);
ans += 2 * cost;
for (int i = x - 1; i >= 1 && inp[i] == 'e'; --i) {
ans += 2;
cp = i;
}
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |