Submission #865475

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
8654752023-10-24 09:01:22faricaElection (BOI18_election)C++14
100 / 100
1231 ms28328 KiB
#include <bits/stdc++.h>
#define long long ll
using namespace std;
const int MAX_N=1e6;
struct Node {
int sum, pref, suf, ans;
Node operator+(Node b) {
Node ret;
ret.sum = sum + b.sum;
ret.pref = max(pref, b.pref + sum);
ret.suf = max(b.suf, suf + b.sum);
ret.ans = max(max(ans + b.sum, b.ans + sum), pref + b.suf);
return ret;
}
};
string s;
Node seg[4*MAX_N];
int L,R;
void build(int node, int l, int r) {
if(l==r) {
if(s[l]=='T') seg[node].sum = seg[node].ans = seg[node].pref = seg[node].suf = 1;
else {
seg[node].sum = -1;
seg[node].pref = seg[node].suf = seg[node].ans = 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...