Submission #565618

#TimeUsernameProblemLanguageResultExecution timeMemory
565618Abdulmohsen1284Election (BOI18_election)C++14
28 / 100
3039 ms800 KiB
#include"bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<class x> using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long a[2000005],up[2000005]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n; cin>>n; string s; cin>>s; long long q; cin>>q; for(int i=0;i<q;i++) { long long fr,sc; cin>>fr>>sc; long long c=0,t=0,del=0; vector <char> cur; for(int i=fr-1;i<sc;i++) { cur.push_back(s[i]); if(s[i]=='C') c++; else t++; if(t>c) { t--; del++; cur.pop_back(); } } reverse(cur.begin(),cur.end()); c=0; t=0; for(int i=0;i<cur.size();i++) { //cout<<cur[i]; if(cur[i]=='C') c++; else t++; if(t>c) { t--; del++; } } cout<<del<<"\n"; } }

Compilation message (stderr)

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