# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173428 | jhwest2 | JOIOJI (JOI14_joioji) | C++14 | 46 ms | 6276 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>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int N;
string s;
map<pii, int> mp;
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> N >> s;
int ans = 0;
pii ret = {0, 0}; mp[ret] = 0;
for (int i=0; i<s.size(); i++) {
if (s[i] == 'J') ++ret.va, ++ret.vb;
if (s[i] == 'O') --ret.va;
if (s[i] == 'I') --ret.vb;
if (mp.find(ret) == mp.end()) mp[ret] = i+1;
else ans = max(ans, i+1 - mp[ret]);
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |