제출 #156032

#제출 시각아이디문제언어결과실행 시간메모리
156032EntityITJOIOJI (JOI14_joioji)C++14
100 / 100
102 ms18168 KiB
#include<bits/stdc++.h>

using namespace std;

const int N = (int)2e5 + 5;
int n, prefJ[N], prefO[N], prefI[N], ans;
map< pair<int, int>, set<int> > pos;

int main() {
    scanf(" %d", &n);

    pos[ make_pair(prefJ[0] - prefO[0], prefO[0] - prefI[0]) ].insert(0);
    for (int i = 1; i <= n; ++i) {
        prefJ[i] = prefJ[i - 1];
        prefO[i] = prefO[i - 1];
        prefI[i] = prefI[i - 1];
        char c; scanf(" %c", &c);
        if (c == 'J') ++prefJ[i];
        if (c == 'O') ++prefO[i];
        if (c == 'I') ++prefI[i];

        pos[ make_pair(prefJ[i] - prefO[i], prefO[i] - prefI[i]) ].insert(i);
    }

    for (auto _ : pos) {
        ans = max(ans, *_.second.rbegin() - *_.second.begin() );
    }

    printf("%d\n", ans);

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

joioji.cpp: In function 'int main()':
joioji.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %d", &n);
     ~~~~~^~~~~~~~~~~
joioji.cpp:17:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         char c; scanf(" %c", &c);
                 ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...