답안 #320091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320091 2020-11-07T13:59:20 Z YJU JOIOJI (JOI14_joioji) C++14
100 / 100
44 ms 6256 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;
	m[mp(0,0)]=0;
	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;
}

# 결과 실행 시간 메모리 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 512 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 492 KB Output is correct
2 Correct 7 ms 1004 KB Output is correct
3 Correct 11 ms 1536 KB Output is correct
4 Correct 22 ms 2276 KB Output is correct
5 Correct 34 ms 3320 KB Output is correct
6 Correct 42 ms 3448 KB Output is correct
7 Correct 44 ms 3952 KB Output is correct
8 Correct 41 ms 3312 KB Output is correct
9 Correct 42 ms 3696 KB Output is correct
10 Correct 42 ms 3440 KB Output is correct
11 Correct 36 ms 5104 KB Output is correct
12 Correct 33 ms 2160 KB Output is correct
13 Correct 28 ms 1520 KB Output is correct
14 Correct 31 ms 6256 KB Output is correct
15 Correct 18 ms 1144 KB Output is correct