# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647100 | Alenygam | Election (BOI18_election) | C++14 | 633 ms | 41416 KiB |
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 <bits/stdc++.h>
using namespace std;
struct Node {
long long mpf = 0;
long long msf = 0;
long long sum = 0;
long long ans = 0;
};
struct SegTree {
vector<Node> segTree;
int realSize;
SegTree(int N, string &data) {
realSize = 1<<(int)ceil(log2(N));
segTree.resize(realSize * 2);
for (int i = 0; i < N; i++) {
if (data[i] == 'T') segTree[realSize + i] = {1, 1, 1, 1};
else segTree[realSize + i] = {0, 0, -1, 0};
}
for (int i = realSize - 1; i > 0; i--) {
segTree[i].mpf = max(segTree[i * 2].mpf, segTree[i * 2].sum + segTree[i * 2 + 1].mpf);
segTree[i].msf = max(segTree[i * 2 + 1].msf, segTree[i * 2 + 1].sum + segTree[i * 2].msf);
segTree[i].sum = segTree[i * 2].sum + segTree[i * 2 + 1].sum;
segTree[i].ans = max({
segTree[i * 2].sum + segTree[i * 2 + 1].ans,
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |