Submission #320090

# Submission time Handle Problem Language Result Execution time Memory
320090 2020-11-07T13:57:41 Z YJU JOIOJI (JOI14_joioji) C++14
95 / 100
52 ms 6264 KB
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=2e5+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<60);
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()

ll n,J,O,I,ans;
map<pll,ll> m;
string s;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>s;
	REP(i,SZ(s)){
		if(s[i]=='J')J++;
		if(s[i]=='O')O++;
		if(s[i]=='I')I++;
		if(m.find(mp(J-O,J-I))==m.end())m[mp(J-O,J-I)]=i+1;
		else ans=max(ans,i+1-m[mp(J-O,J-I)]);
	}
	cout<<ans<<"\n";
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 396 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 492 KB Output is correct
2 Correct 7 ms 1004 KB Output is correct
3 Correct 11 ms 1516 KB Output is correct
4 Correct 22 ms 2284 KB Output is correct
5 Correct 34 ms 3568 KB Output is correct
6 Correct 52 ms 3696 KB Output is correct
7 Correct 43 ms 4208 KB Output is correct
8 Correct 44 ms 3572 KB Output is correct
9 Correct 43 ms 3972 KB Output is correct
10 Correct 41 ms 3576 KB Output is correct
11 Correct 36 ms 5236 KB Output is correct
12 Correct 32 ms 2416 KB Output is correct
13 Correct 27 ms 1656 KB Output is correct
14 Correct 31 ms 6264 KB Output is correct
15 Correct 19 ms 1392 KB Output is correct