답안 #8232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
8232 2014-09-07T10:52:39 Z baneling100 JOIOJI (JOI14_joioji) C++
100 / 100
36 ms 6948 KB
#include <stdio.h>
#include <algorithm>
#include <map>

using namespace std;

typedef pair <int,int> ppair;
typedef pair <ppair,int> pppair;
map <pppair,int> Map;
map <pppair,int> :: iterator it;
int N, J, O, I, Ans;
char S[200002];

void input(void) {

    scanf("%d %s",&N,&S[1]);
}

void process(void) {

    int i, temp;

    Map.insert(make_pair(make_pair(make_pair(0,0),0),0));
    for(i=1 ; i<=N ; i++) {
        if(S[i]=='J')
            J++;
        else if(S[i]=='O')
            O++;
        else
            I++;
        temp=min(min(J,O),I);
        it=Map.find(make_pair(make_pair(J-temp,O-temp),I-temp));
        if(it==Map.end())
            Map.insert(make_pair(make_pair(make_pair(J-temp,O-temp),I-temp),i));
        else
            if(Ans<i-it->second)
                Ans=i-it->second;
    }
}

void output(void) {

    printf("%d",Ans);
}

int main(void) {

    input();
    process();
    output();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1404 KB Output is correct
2 Correct 0 ms 1404 KB Output is correct
3 Correct 0 ms 1404 KB Output is correct
4 Correct 0 ms 1404 KB Output is correct
5 Correct 0 ms 1404 KB Output is correct
6 Correct 0 ms 1404 KB Output is correct
7 Correct 0 ms 1404 KB Output is correct
8 Correct 0 ms 1404 KB Output is correct
9 Correct 0 ms 1404 KB Output is correct
10 Correct 0 ms 1404 KB Output is correct
11 Correct 0 ms 1404 KB Output is correct
12 Correct 0 ms 1404 KB Output is correct
13 Correct 0 ms 1404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1404 KB Output is correct
2 Correct 0 ms 1404 KB Output is correct
3 Correct 0 ms 1404 KB Output is correct
4 Correct 0 ms 1404 KB Output is correct
5 Correct 0 ms 1404 KB Output is correct
6 Correct 0 ms 1404 KB Output is correct
7 Correct 0 ms 1404 KB Output is correct
8 Correct 0 ms 1404 KB Output is correct
9 Correct 0 ms 1404 KB Output is correct
10 Correct 0 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1536 KB Output is correct
2 Correct 0 ms 1932 KB Output is correct
3 Correct 8 ms 2328 KB Output is correct
4 Correct 12 ms 3120 KB Output is correct
5 Correct 28 ms 4176 KB Output is correct
6 Correct 36 ms 4308 KB Output is correct
7 Correct 32 ms 4704 KB Output is correct
8 Correct 36 ms 4176 KB Output is correct
9 Correct 36 ms 4440 KB Output is correct
10 Correct 32 ms 4176 KB Output is correct
11 Correct 32 ms 5892 KB Output is correct
12 Correct 12 ms 2988 KB Output is correct
13 Correct 20 ms 2328 KB Output is correct
14 Correct 24 ms 6948 KB Output is correct
15 Correct 12 ms 1932 KB Output is correct