Submission #328537

# Submission time Handle Problem Language Result Execution time Memory
328537 2020-11-17T03:53:45 Z sumit_kk10 JOIOJI (JOI14_joioji) C++14
95 / 100
50 ms 6264 KB
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

void solve(){
	int n, j = 0, ii = 0, ans = 0, o = 0;
	cin >> n;
	string s;
	cin >> s;
	map<pair<int, int>, int> mp;
	mp[{0, 0}] = 1;
	for(int i = 1; i < s.size(); ++i){
		if(s[i] == 'J') ++j;
		if(s[i] == 'O') ++o;
		if(s[i] == 'I') ++ii;
		if(mp.find({j - o, j - ii}) == mp.end())
			mp[{j - o, j - ii}] = i + 1;
		else
			ans = max(ans, i + 1 - mp[{j - o, j - ii}]);
	}
	cout << ans << '\n';
}

int main(){
	fast;
	int t = 1;
	// cin >> t;
	while(t--)
		solve();
	return 0;
}

Compilation message

joioji.cpp: In function 'void solve()':
joioji.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i = 1; i < s.size(); ++i){
      |                 ~~^~~~~~~~~~
# 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 384 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 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 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 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 512 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 8 ms 1004 KB Output is correct
3 Correct 11 ms 1644 KB Output is correct
4 Correct 22 ms 2284 KB Output is correct
5 Correct 34 ms 3448 KB Output is correct
6 Correct 49 ms 3704 KB Output is correct
7 Correct 49 ms 4088 KB Output is correct
8 Correct 50 ms 3576 KB Output is correct
9 Correct 44 ms 3832 KB Output is correct
10 Correct 42 ms 3596 KB Output is correct
11 Correct 35 ms 5240 KB Output is correct
12 Correct 30 ms 2296 KB Output is correct
13 Correct 26 ms 1656 KB Output is correct
14 Correct 30 ms 6264 KB Output is correct
15 Correct 18 ms 1400 KB Output is correct