Submission #366988

# Submission time Handle Problem Language Result Execution time Memory
366988 2021-02-15T22:51:11 Z MilosMilutinovic JOIOJI (JOI14_joioji) C++14
95 / 100
48 ms 6124 KB
#include <bits/stdc++.h>
using namespace std;
const int N=2000050;
int n;
char s[N];
int main(){
	scanf("%i%s",&n,s);
	map<pair<int,int>,int> lst;
	map<char,int> cnt;
	int ans=0;
	lst[{0,0}]=1;
	for(int i=0;i<n;i++){
		cnt[s[i]]++;
		pair<int,int> curr;
		curr.first=cnt['J']-cnt['O'];
		curr.second=cnt['J']-cnt['I'];
		if(lst[curr]!=0){
			ans=max(ans,i-lst[curr]+1);
		}else lst[curr]=i+1;
	}
	printf("%i",ans);
	return 0;
}

Compilation message

joioji.cpp: In function 'int main()':
joioji.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |  scanf("%i%s",&n,s);
      |  ~~~~~^~~~~~~~~~~~~
# 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 512 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 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 364 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 2 ms 364 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 12 ms 1388 KB Output is correct
4 Correct 23 ms 2156 KB Output is correct
5 Correct 36 ms 3308 KB Output is correct
6 Correct 45 ms 3436 KB Output is correct
7 Correct 48 ms 4076 KB Output is correct
8 Correct 44 ms 3308 KB Output is correct
9 Correct 45 ms 3692 KB Output is correct
10 Correct 43 ms 3436 KB Output is correct
11 Correct 40 ms 5100 KB Output is correct
12 Correct 33 ms 2156 KB Output is correct
13 Correct 31 ms 1516 KB Output is correct
14 Correct 42 ms 6124 KB Output is correct
15 Correct 23 ms 1132 KB Output is correct