Submission #221936

#TimeUsernameProblemLanguageResultExecution timeMemory
221936mhy908스탬프 수집 (JOI16_ho_t2)C++14
100 / 100
9 ms3712 KiB
#include <bits/stdc++.h> using namespace std; typedef long long LL; int n; char str[100010]; LL J[100010], JO[100010], OI[100010], I[100010], ans, ans2; int main(){ scanf("%d %s", &n, str+1); for(int i=1; i<=n; i++){ J[i]=J[i-1], JO[i]=JO[i-1]; if(str[i]=='J')J[i]++; if(str[i]=='O')JO[i]+=J[i]; if(str[i]=='I')ans+=JO[i]; } for(int i=n; i>=1; i--){ I[i]=I[i+1], OI[i]=OI[i+1]; if(str[i]=='I')I[i]++; if(str[i]=='O')OI[i]+=I[i]; } for(int i=1; i<=n+1; i++){ LL tmp=max(max(OI[i], JO[i-1]), J[i-1]*I[i]); ans2=max(ans2, tmp); } printf("%lld", ans+ans2); }

Compilation message (stderr)

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