# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
384535 |
2021-04-01T20:24:28 Z |
Peti |
Election (BOI18_election) |
C++14 |
|
3000 ms |
1020 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
cin.sync_with_stdio(false);
cin.tie(0);
int n, q;
string s;
cin>>n;
cin>>s;
cin>>q;
for(int i = 0; i < q; i++){
int l, r;
cin>>l>>r;
int x = 0;
vector<bool> kell(n, false);
for(int j = l-1; j < r; j++){
if(s[j] == 'T' && x > 0){
x--;
kell[j] = true;
} else if(s[j] == 'C')
x++;
}
x = 0;
for(int j = r-1; j >= l-1; j--){
if(s[j] == 'T' && kell[j]){
if(x == 0)
kell[j] = false;
else
x--;
} else if(s[j] == 'C')
x++;
}
int meg = 0;
for(int j = l-1; j < r; j++)
if(s[j] == 'T' && !kell[j])
meg++;
cout<<meg<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
364 KB |
Output is correct |
2 |
Correct |
10 ms |
364 KB |
Output is correct |
3 |
Correct |
9 ms |
364 KB |
Output is correct |
4 |
Correct |
10 ms |
364 KB |
Output is correct |
5 |
Correct |
7 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
364 KB |
Output is correct |
2 |
Correct |
10 ms |
364 KB |
Output is correct |
3 |
Correct |
9 ms |
364 KB |
Output is correct |
4 |
Correct |
10 ms |
364 KB |
Output is correct |
5 |
Correct |
7 ms |
512 KB |
Output is correct |
6 |
Execution timed out |
3039 ms |
1020 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
364 KB |
Output is correct |
2 |
Correct |
10 ms |
364 KB |
Output is correct |
3 |
Correct |
9 ms |
364 KB |
Output is correct |
4 |
Correct |
10 ms |
364 KB |
Output is correct |
5 |
Correct |
7 ms |
512 KB |
Output is correct |
6 |
Execution timed out |
3039 ms |
1020 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |