Submission #6064

#TimeUsernameProblemLanguageResultExecution timeMemory
6064aintaJOIOJI (JOI14_joioji)C++98
100 / 100
44 ms3624 KiB
#pragma warning(disable:4996) #include<stdio.h> #include<algorithm> using namespace std; int n; char p[200010]; struct A{ int a, b, ord; bool operator <(const A &p)const{ return a != p.a ? a < p.a : b != p.b ? b < p.b : ord < p.ord; } }w[200010]; int main() { int i, t, M = 0; scanf("%d", &n); scanf("%s", p + 1); for (i = 1; i <= n; i++){ w[i] = w[i - 1]; if (p[i] == 'J')w[i].a++, w[i].b++; else if (p[i] == 'O')w[i].a--; else w[i].b--; w[i].ord = i; } sort(w, w + n + 1); for (i = 0; i <= n; i++){ if (i && w[i].a == w[i - 1].a && w[i].b == w[i - 1].b){ if (M < w[i].ord - t)M = w[i].ord - t; } else{ t = w[i].ord; } } printf("%d\n", M); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...