# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
806991 |
2023-08-04T12:02:13 Z |
MODDI |
Election (BOI18_election) |
C++14 |
|
3000 ms |
1148 KB |
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int maxn = 500005;
int n;
string s;
int main()
{
cin >> n >> s;
s = '#' + s;
int q;
cin >> q;
while (q--)
{
int l, r;
cin >> l >> r;
vector<bool> gone(n + 5, false);
int c = 0;
int t = 0;
for (int i = l; i <= r; ++i)
{
if (s[i] == 'C')
{
c++;
}
else
{
if (t + 1 <= c)
{
++t;
}
else
{
gone[i] = true;
}
}
}
c = 0;
t = 0;
for (int i = r; i >= l; --i)
{
if (s[i] == 'C')
{
++c;
}
else if (gone[i] == false)
{
if (t + 1 <= c)
{
++t;
}
else
{
gone[i] = true;
}
}
}
int ans = 0;
for (int i = l; i <= r; ++i)
{
ans += gone[i];
}
cout << ans << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
332 KB |
Output is correct |
2 |
Correct |
8 ms |
212 KB |
Output is correct |
3 |
Correct |
8 ms |
308 KB |
Output is correct |
4 |
Correct |
8 ms |
312 KB |
Output is correct |
5 |
Correct |
9 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
332 KB |
Output is correct |
2 |
Correct |
8 ms |
212 KB |
Output is correct |
3 |
Correct |
8 ms |
308 KB |
Output is correct |
4 |
Correct |
8 ms |
312 KB |
Output is correct |
5 |
Correct |
9 ms |
340 KB |
Output is correct |
6 |
Execution timed out |
3048 ms |
1148 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
332 KB |
Output is correct |
2 |
Correct |
8 ms |
212 KB |
Output is correct |
3 |
Correct |
8 ms |
308 KB |
Output is correct |
4 |
Correct |
8 ms |
312 KB |
Output is correct |
5 |
Correct |
9 ms |
340 KB |
Output is correct |
6 |
Execution timed out |
3048 ms |
1148 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |