답안 #772640

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
772640 2023-07-04T09:38:45 Z hgmhc JOIOJI (JOI14_joioji) C++17
95 / 100
32 ms 6104 KB
#include <bits/stdc++.h>
using namespace std; using ii = pair<int,int>; using ll = long long;
#define rep(i,a,b) for (auto i = (a); i <= (b); ++i)
#define per(i,a,b) for (auto i = (b); i >= (a); --i)
#define all(x) begin(x), end(x)
#define siz(x) int((x).size())
#define Mup(x,y) x = max(x,y)
#define mup(x,y) x = min(x,y)
#define fi first
#define se second
#define dbg(...) fprintf(stderr,__VA_ARGS__)


const int N = 2e5+3;
int n, ans;
char s[N];
map<ii,ii> m;

int main() {
    scanf("%d %s ", &n, s+1);
    int j=0, o=0, i=0;
    rep(k,1,n) {
        if(s[k]=='J')j++;
        if(s[k]=='O')o++;
        if(s[k]=='I')i++;
        if (m.count({j-o,o-i})) m[{j-o,o-i}].se = k;
        else m[{j-o,o-i}] = {k,k};
    }
    for (auto [k,v] : m) Mup(ans, v.se-v.fi);
    printf("%d", ans);
}

Compilation message

joioji.cpp: In function 'int main()':
joioji.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d %s ", &n, s+1);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 8 ms 1324 KB Output is correct
4 Correct 16 ms 2260 KB Output is correct
5 Correct 25 ms 3404 KB Output is correct
6 Correct 30 ms 3648 KB Output is correct
7 Correct 32 ms 4052 KB Output is correct
8 Correct 31 ms 3396 KB Output is correct
9 Correct 32 ms 3664 KB Output is correct
10 Correct 30 ms 3476 KB Output is correct
11 Correct 22 ms 5204 KB Output is correct
12 Correct 18 ms 2264 KB Output is correct
13 Correct 15 ms 1600 KB Output is correct
14 Correct 23 ms 6104 KB Output is correct
15 Correct 11 ms 1236 KB Output is correct