# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1002674 | Andrey | Election (BOI18_election) | C++14 | 3044 ms | 2176 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |