Submission #759339

#TimeUsernameProblemLanguageResultExecution timeMemory
759339gvancakElection (BOI18_election)C++11
28 / 100
3064 ms26144 KiB
#include <bits/stdc++.h> #define ll long long #define s second #define f first #define pb push_back using namespace std; ll n,k,a[1000005],b[1000005],dp[1000005],ans[1000005],mx,l,z,x,q,r; map <ll,ll> m; vector <ll> v[1000005]; string s; bool ok; int main() { cin>>n; cin>>s; for (int i=0; i<s.size(); i++) if (s[i]=='C') a[i+1]=1; else a[i+1]=-1; for (int i=1; i<=n; i++) b[i]=a[i]; //prefix da sufix a[i]>=0 gvinda cin>>q; for (int o=1; o<=q; o++){ cin>>l>>r; x=0; k=0; for (int i=l; i<=r; i++){ x+=b[i]; if (x<0){ b[i]=0; k++; x=0; } } x=0; for (int i=r; i>=l; i--){ x+=b[i]; if (x<0){ b[i]=0; k++; x=0; } } cout<<k<<endl; for (int i=1; i<=n; i++) b[i]=a[i]; } }

Compilation message (stderr)

election.cpp: In function 'int main()':
election.cpp:16:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int i=0; i<s.size(); i++)
      |                   ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...