Submission #366985

#TimeUsernameProblemLanguageResultExecution timeMemory
366985MilosMilutinovicJOIOJI (JOI14_joioji)C++14
95 / 100
45 ms6252 KiB
#include <bits/stdc++.h> using namespace std; const int N=2000050; int n; char s[N]; int main(){ scanf("%i%s",&n,s); map<pair<int,int>,int> lst; map<char,int> cnt; int ans=0; for(int i=0;i<n;i++){ cnt[s[i]]++; pair<int,int> curr; curr.first=cnt['J']-cnt['O']; curr.second=cnt['J']-cnt['I']; if(lst[curr]!=0){ ans=max(ans,i-lst[curr]+1); }else lst[curr]=i+1; } printf("%i",ans); return 0; }

Compilation message (stderr)

joioji.cpp: In function 'int main()':
joioji.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |  scanf("%i%s",&n,s);
      |  ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...