답안 #211779

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
211779 2020-03-21T08:52:19 Z jzh JOIOJI (JOI14_joioji) C++14
95 / 100
73 ms 11880 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,i,x,y,a=0,b=0,ans=0;
    string s;
    cin>>n>>s;
    map<pair<ll,ll>,ll>mini,maxi;
    s='.'+s;
    for (i=1;i<=n;i++){
        if (s[i]=='J')a++;
        else if (s[i]=='O')a--;
        if (s[i]=='O')b++;
        else if (s[i]=='I')b--;
        if (mini.find({a,b})==mini.end())mini[{a,b}]=i;
        maxi[{a,b}]=i;
    }
    for (auto it:mini){
        if (it.second!=maxi[it.first]){
            ans=max(ans,maxi[it.first]-it.second);
        }
    }

    cout<<ans<<'\n';
}

Compilation message

joioji.cpp: In function 'int main()':
joioji.cpp:7:12: warning: unused variable 'x' [-Wunused-variable]
     ll n,i,x,y,a=0,b=0,ans=0;
            ^
joioji.cpp:7:14: warning: unused variable 'y' [-Wunused-variable]
     ll n,i,x,y,a=0,b=0,ans=0;
              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Incorrect 5 ms 384 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 640 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 640 KB Output is correct
10 Correct 6 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 768 KB Output is correct
2 Correct 14 ms 1536 KB Output is correct
3 Correct 25 ms 2688 KB Output is correct
4 Correct 37 ms 4092 KB Output is correct
5 Correct 59 ms 6384 KB Output is correct
6 Correct 65 ms 6592 KB Output is correct
7 Correct 69 ms 7616 KB Output is correct
8 Correct 64 ms 6336 KB Output is correct
9 Correct 73 ms 7104 KB Output is correct
10 Correct 65 ms 6460 KB Output is correct
11 Correct 65 ms 9816 KB Output is correct
12 Correct 47 ms 3912 KB Output is correct
13 Correct 37 ms 2632 KB Output is correct
14 Correct 69 ms 11880 KB Output is correct
15 Correct 28 ms 1992 KB Output is correct