제출 #1208086

#제출 시각아이디문제언어결과실행 시간메모리
1208086PlayVoltz스탬프 수집 (JOI16_ho_t2)C++20
100 / 100
3 ms840 KiB
#include <cstdio> #include <stdio.h> #include <stdbool.h> #include <iostream> #include <map> #include <vector> #include <climits> #include <stack> #include <string> #include <queue> #include <algorithm> #include <set> #include <unordered_set> #include <unordered_map> #include <cmath> #include <cctype> #include <bitset> #include <iomanip> #include <cstring> #include <numeric> #include <cassert> #include <chrono> using namespace std; #define int long long #define pii pair<int, int> #define mp make_pair #define pb push_back #define fi first #define se second int calc(string s){ int j=0, o=0, i=0; for (auto a:s){ if (a=='J')++j; else if (a=='O')o+=j; else i+=o; } return i; } int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, mx=0, j=0, i=0; string s; cin>>n>>s; for (auto a:s)if (a=='I')++i; for (auto a:s){ if (a=='J')++j; else if (a=='I')--i; mx=max(mx, j*i); } cout<<max({mx+calc(s), calc("J"+s), calc(s+"I")}); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...