Submission #51658

#TimeUsernameProblemLanguageResultExecution timeMemory
51658gs13105스탬프 수집 (JOI16_ho_t2)C++17
100 / 100
7 ms3840 KiB
#include <cstdio> #include <cstdlib> #include <cstring> #include <cassert> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <iterator> using namespace std; char arr[100010]; long long J[100010]; long long JO[100010]; long long I[100010]; long long OI[100010]; int main() { //freopen("in", "r", stdin); //freopen("out", "w", stdout); int n, i; scanf("%d%s", &n, arr + 1); for(i = 1; i <= n; i++) J[i] = (arr[i] == 'J' ? 1 : 0) + J[i - 1]; for(i = 1; i <= n; i++) JO[i] = (arr[i] == 'O' ? J[i - 1] : 0) + JO[i - 1]; for(i = n; i >= 1; i--) I[i] = (arr[i] == 'I' ? 1 : 0) + I[i + 1]; for(i = n; i >= 1; i--) OI[i] = (arr[i] == 'O' ? I[i + 1] : 0) + OI[i + 1]; long long JOI = 0; for(i = 1; i <= n; i++) if(arr[i] == 'I') JOI += JO[i - 1]; long long res = 0; for(i = 0; i <= n; i++) { res = max(OI[i + 1], res); // J res = max(J[i] * I[i+1], res); // O res = max(JO[i], res); // I } res += JOI; printf("%lld\n", res); return 0; }

Compilation message (stderr)

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