Submission #208384

#TimeUsernameProblemLanguageResultExecution timeMemory
208384bensonlzlJOIOJI (JOI14_joioji)C++14
100 / 100
74 ms10276 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pi; map<pi,vector<int> > m; int N, curJ = 0, curO = 0, curI = 0; char x; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> N; m[pi(0,0)] = vector<int>(1,0); for (int i = 1; i <= N; ++i){ cin >> x; if (x == 'J') curJ++; else if (x == 'O') curO++; else curI++; if (m.find(pi(curO-curJ,curI-curO)) == m.end()){ m[pi(curO-curJ,curI-curO)] = vector<int>(); } m[pi(curO-curJ,curI-curO)].push_back(i); } int maxi = 0; for (auto it : m){ maxi = max(maxi,it.second.back()-it.second[0]); } cout << maxi << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...