# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
364858 | 2021-02-10T09:52:38 Z | Sparky_09 | JOIOJI (JOI14_joioji) | C++17 | 45 ms | 6264 KB |
#include "bits/stdc++.h" using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define trav(a, x) for(auto& a : x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<ll, ll> pii; typedef vector<ll> vi; typedef vector<pii> vpi; void usaco(string s){ freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); #ifdef LOCAL_DEFINE freopen("input.txt", "r", stdin); #endif int n; cin >> n; string s; cin >> s; map<pair<int, int>, int> m; m[make_pair(0, 0)] = 0; int js=0,is=0,os=0,ans=0; rep(i, 0, n){ if(s[i]=='J') js++; else if(s[i]=='O') os++; else is++; if(m.find(make_pair(js-os,js-is))==m.end()) m[make_pair(js-os,js-is)] = i+1; else ans = max(ans, i+1-m[make_pair(js-os,js-is)]); } cout << ans << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 512 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 512 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 492 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 492 KB | Output is correct |
10 | Correct | 2 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 492 KB | Output is correct |
2 | Correct | 7 ms | 1024 KB | Output is correct |
3 | Correct | 11 ms | 1516 KB | Output is correct |
4 | Correct | 22 ms | 2412 KB | Output is correct |
5 | Correct | 39 ms | 3576 KB | Output is correct |
6 | Correct | 42 ms | 3704 KB | Output is correct |
7 | Correct | 45 ms | 4108 KB | Output is correct |
8 | Correct | 41 ms | 3576 KB | Output is correct |
9 | Correct | 42 ms | 3832 KB | Output is correct |
10 | Correct | 42 ms | 3596 KB | Output is correct |
11 | Correct | 38 ms | 5240 KB | Output is correct |
12 | Correct | 29 ms | 2296 KB | Output is correct |
13 | Correct | 26 ms | 1688 KB | Output is correct |
14 | Correct | 30 ms | 6264 KB | Output is correct |
15 | Correct | 23 ms | 1400 KB | Output is correct |