제출 #105704

#제출 시각아이디문제언어결과실행 시간메모리
105704Pro_ktmrJOIOJI (JOI14_joioji)C++14
100 / 100
37 ms5004 KiB
#include <iostream> #include <iomanip> #include <fstream> #include <stdio.h> #include <math.h> #include <time.h> #include <string> #include <tuple> #include <vector> #include <map> #include <unordered_map> #include <list> #include <set> #include <stack> #include <queue> #include <cstdlib> #include <algorithm> #include <random> #include <cassert> using namespace std; #define LL long long #define MP(a, b) make_pair(a, b) #define POWER9 1000000000 #define MOD POWER9+7 #undef INT_MIN #undef INT_MAX #define INT_MIN -2147483647 #define INT_MAX 2147483647 #define LL_MIN (LL)-9223372036854775807 #define LL_MAX (LL)9223372036854775807 #define PI 3.14159265359 #define MIX(a,b,c,d) make_pair(make_pair(a,b),make_pair(c,d)) int N; string S; vector<pair<pair<int,int>,pair<int,int> > > wa; int main(){ cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(9); cin >> N >> S; wa.push_back(MIX(0,0,0,0)); for(int i=0; i<N; i++){ wa.push_back(wa.back()); wa.back().second.second++; if(S[i] == 'J') wa.back().first.first++; if(S[i] == 'O') wa.back().first.second++; if(S[i] == 'I') wa.back().second.first++; int m = min({wa.back().first.first,wa.back().first.second,wa.back().second.first}); wa.back().first.first -= m; wa.back().first.second -= m; wa.back().second.first -= m; } sort(wa.begin(), wa.end()); int l = 0; int ans = 0; for(int i=1; i<=N; i++){ if(wa[l].first == wa[i].first && wa[l].second.first == wa[i].second.first){ ans = max(ans, wa[i].second.second-wa[l].second.second); } else{ l = i; } } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...