# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211780 | 2020-03-21T08:54:22 Z | jzh | JOIOJI (JOI14_joioji) | C++14 | 75 ms | 11752 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n,i,x,y,a=0,b=0,ans=0; string s; cin>>n>>s; map<pair<ll,ll>,ll>mini,maxi; s='.'+s; mini[{0,0}]=0; maxi[{0,0}]=0; for (i=1;i<=n;i++){ if (s[i]=='J')a++; else if (s[i]=='O')a--; if (s[i]=='O')b++; else if (s[i]=='I')b--; if (mini.find({a,b})==mini.end())mini[{a,b}]=i; maxi[{a,b}]=i; } for (auto it:mini){ if (it.second!=maxi[it.first]){ ans=max(ans,maxi[it.first]-it.second); } } cout<<ans<<'\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 416 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 512 KB | Output is correct |
4 | Correct | 6 ms | 512 KB | Output is correct |
5 | Correct | 6 ms | 512 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 512 KB | Output is correct |
8 | Correct | 6 ms | 512 KB | Output is correct |
9 | Correct | 6 ms | 640 KB | Output is correct |
10 | Correct | 6 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 768 KB | Output is correct |
2 | Correct | 14 ms | 1536 KB | Output is correct |
3 | Correct | 21 ms | 2432 KB | Output is correct |
4 | Correct | 37 ms | 3956 KB | Output is correct |
5 | Correct | 75 ms | 6288 KB | Output is correct |
6 | Correct | 67 ms | 6464 KB | Output is correct |
7 | Correct | 70 ms | 7360 KB | Output is correct |
8 | Correct | 62 ms | 6160 KB | Output is correct |
9 | Correct | 65 ms | 6720 KB | Output is correct |
10 | Correct | 61 ms | 6208 KB | Output is correct |
11 | Correct | 63 ms | 9688 KB | Output is correct |
12 | Correct | 46 ms | 3784 KB | Output is correct |
13 | Correct | 35 ms | 2384 KB | Output is correct |
14 | Correct | 68 ms | 11752 KB | Output is correct |
15 | Correct | 25 ms | 1864 KB | Output is correct |