Submission #1002674

#TimeUsernameProblemLanguageResultExecution timeMemory
1002674AndreyElection (BOI18_election)C++14
28 / 100
3044 ms2176 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); int n,q,l,r; cin >> n; string s; cin >> s; vector<int> haha(n+1); cin >> q; for(int i = 1; i <= n; i++) { if(s[i-1] == 'C') { haha[i] = 1; } else { haha[i] = -1; } } for(int i = 0; i < q; i++) { cin >> l >> r; vector<int> bruh(r-l+1); for(int j = l; j <= r; j++) { bruh[j-l] = haha[j]; } int ans = 0,br = 0; for(int j = 0; j < bruh.size(); j++) { br+=bruh[j]; if(br < 0) { br++; bruh[j] = 0; ans++; } } br = 0; for(int j = bruh.size()-1; j >= 0; j--) { br+=bruh[j]; if(br < 0) { br++; bruh[j] = 0; ans++; } } cout << ans << "\n"; } return 0; }

Compilation message (stderr)

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