Submission #117157

#TimeUsernameProblemLanguageResultExecution timeMemory
117157onjo0127스탬프 수집 (JOI16_ho_t2)C++11
100 / 100
34 ms1380 KiB
#include <bits/stdc++.h> using namespace std; char S[100009]; int J[100009], I[100009]; int main() { int N; scanf("%d",&N); for(int i=1; i<=N; i++) scanf(" %c", &S[i]); for(int i=1; i<=N; i++) J[i] = J[i-1] + (S[i] == 'J'); for(int i=N; i>=1; i--) I[i] = I[i+1] + (S[i] == 'I'); long long s1 = 0, s2 = 0, s3 = 0, mx = 0; for(int i=1; i<=N; i++) { if(S[i] == 'O') { s1 += 1LL * (J[i] + 1) * I[i]; s2 += 1LL * J[i] * (I[i] + 1); s3 += 1LL * J[i] * I[i]; } mx = max(mx, 1LL * J[i] * I[i]); } printf("%lld", max({s1, s2, s3 + mx})); return 0; }

Compilation message (stderr)

2016_ho_t2.cpp: In function 'int main()':
2016_ho_t2.cpp:8:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int N; scanf("%d",&N);
            ~~~~~^~~~~~~~~
2016_ho_t2.cpp:9:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=N; i++) scanf(" %c", &S[i]);
                             ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...