# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
200516 |
2020-02-07T03:40:50 Z |
arnold518 |
JOIOJI (JOI14_joioji) |
C++14 |
|
50 ms |
6264 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2e5;
int N;
char S[MAXN+10];
struct tup
{
int a, b, c;
bool operator < (const tup &p) const
{
if(a!=p.a) return a<p.a;
if(b!=p.b) return b<p.b;
return c<p.c;
}
};
map<tup, int> M;
int ans;
int main()
{
int i, j;
scanf("%d%s", &N, S+1);
int J=0, O=0, I=0;
M[{0, 0, 0}]=0;
for(i=1; i<=N; i++)
{
if(S[i]=='J') J++;
else if(S[i]=='O') O++;
else I++;
int p, q, r;
p=J-min({J, O, I});
q=O-min({J, O, I});
r=I-min({J, O, I});
if(M.find({p, q, r})!=M.end()) ans=max(ans, i-M[{p, q, r}]);
else M[{p, q, r}]=i;
}
printf("%d", ans);
}
Compilation message
joioji.cpp: In function 'int main()':
joioji.cpp:28:9: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
joioji.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%s", &N, S+1);
~~~~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
380 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
504 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
380 KB |
Output is correct |
8 |
Correct |
6 ms |
504 KB |
Output is correct |
9 |
Correct |
9 ms |
504 KB |
Output is correct |
10 |
Correct |
6 ms |
508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
504 KB |
Output is correct |
2 |
Correct |
11 ms |
1016 KB |
Output is correct |
3 |
Correct |
15 ms |
1400 KB |
Output is correct |
4 |
Correct |
26 ms |
2296 KB |
Output is correct |
5 |
Correct |
38 ms |
3468 KB |
Output is correct |
6 |
Correct |
50 ms |
3576 KB |
Output is correct |
7 |
Correct |
47 ms |
4088 KB |
Output is correct |
8 |
Correct |
46 ms |
3448 KB |
Output is correct |
9 |
Correct |
46 ms |
3832 KB |
Output is correct |
10 |
Correct |
46 ms |
3576 KB |
Output is correct |
11 |
Correct |
45 ms |
5280 KB |
Output is correct |
12 |
Correct |
34 ms |
2296 KB |
Output is correct |
13 |
Correct |
36 ms |
1656 KB |
Output is correct |
14 |
Correct |
41 ms |
6264 KB |
Output is correct |
15 |
Correct |
29 ms |
1272 KB |
Output is correct |