답안 #8512

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
8512 2014-09-15T07:08:28 Z gs14004 JOIOJI (JOI14_joioji) C++
100 / 100
64 ms 13812 KB
#include <cstdio>
#include <map>
#include <utility>
using namespace std;
typedef pair<int,int> pi;

char str[200005];
int n;
int res = 0;

multimap<pi,int> mp;
multimap<pi,int> ::iterator it;

int main(){
    scanf("%d %s",&n,str);
    pi x = pi(0,0);
    mp.insert(make_pair(x,0));
    for (int i=0; i<n; i++) {
        if(str[i] == 'J'){
            x.first--;
            x.second--;
        }
        else if(str[i] == 'O') x.first++;
        else x.second++;
        mp.insert(make_pair(x,i+1));
    }
    it = mp.begin();
    while (it != mp.end()) {
        x = (*it).first;
        int t = (*it).second;
        while ((*it).first == x && it != mp.end()) it++;
        it--;
        res = max(res,(*it).second - t);
        it++;
    }
    printf("%d",res);
}
# 결과 실행 시간 메모리 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 1536 KB Output is correct
4 Correct 0 ms 1536 KB Output is correct
5 Correct 0 ms 1536 KB Output is correct
6 Correct 0 ms 1536 KB Output is correct
7 Correct 0 ms 1536 KB Output is correct
8 Correct 0 ms 1536 KB Output is correct
9 Correct 0 ms 1536 KB Output is correct
10 Correct 0 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1932 KB Output is correct
2 Correct 8 ms 3252 KB Output is correct
3 Correct 12 ms 4440 KB Output is correct
4 Correct 28 ms 7608 KB Output is correct
5 Correct 44 ms 10776 KB Output is correct
6 Correct 60 ms 13812 KB Output is correct
7 Correct 52 ms 13812 KB Output is correct
8 Correct 64 ms 13812 KB Output is correct
9 Correct 56 ms 13812 KB Output is correct
10 Correct 48 ms 13812 KB Output is correct
11 Correct 44 ms 12096 KB Output is correct
12 Correct 60 ms 13152 KB Output is correct
13 Correct 48 ms 13284 KB Output is correct
14 Correct 40 ms 11304 KB Output is correct
15 Correct 52 ms 13812 KB Output is correct