Submission #166015

# Submission time Handle Problem Language Result Execution time Memory
166015 2019-11-30T07:55:07 Z oolimry JOIOJI (JOI14_joioji) C++14
100 / 100
80 ms 6304 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int I = 0;
  int J = 0;
  int O = 0;
  typedef pair<int,int> ii;
  map<ii,int> m;
  for(int i = 0;i < n;i++){
    if(s[i] == 'I') I++;
    else if(s[i] == 'O') O++;
    else J++;
    m[ii(O-J,O-I)] = i;
  }
  I = 0, J = 0, O = 0;
  int ans = 0;
  for(int i = 0;i < n;i++){
    if(m.find(ii(O-J,O-I)) != m.end() && m[ii(O-J,O-I)] > i)
      ans = max(ans,m[ii(O-J,O-I)] - i + 1);
    if(s[i] == 'I') I++;
    else if(s[i] == 'O') O++;
    else J++;
  }
  cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 15 ms 1016 KB Output is correct
3 Correct 23 ms 1556 KB Output is correct
4 Correct 39 ms 2284 KB Output is correct
5 Correct 58 ms 3588 KB Output is correct
6 Correct 77 ms 3692 KB Output is correct
7 Correct 76 ms 4228 KB Output is correct
8 Correct 74 ms 3560 KB Output is correct
9 Correct 80 ms 3972 KB Output is correct
10 Correct 74 ms 3560 KB Output is correct
11 Correct 61 ms 5252 KB Output is correct
12 Correct 52 ms 2308 KB Output is correct
13 Correct 37 ms 1668 KB Output is correct
14 Correct 65 ms 6304 KB Output is correct
15 Correct 34 ms 1412 KB Output is correct