#include <iostream>
#include <assert.h>
#include <stdio.h>
#include <iomanip>
#include <utility>
#include <math.h>
#include <time.h>
#include <vector>
#include <set>
#include <map>
#include <conio.h>
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
using namespace std;
const int N = 2005;
int n, q, pref[N], suf[N], l, r, sum[N], ans, cn;
string s;
main()
{
cin >> n >> s;
s = ' ' + s;
for (int i = 1; i <= n; i++)
pref[i] = (s[i] == 'C' ? 1 : -1) + pref[i - 1];
for (int i = n; i >= 1; i--)
suf[i] = (s[i] == 'C' ? 1 : -1) + suf[i + 1];
cin >> q;
while (q--)
{
cn = 0;
ans = 0;
for (int i = 1; i<= n; i++)
sum[i] = 0;
scanf("%d%d", &l, &r);
for (int i = l; i <= r; i++)
{
if ( pref[i] + cn < pref[l - 1] )
{
cn++;
sum[l] += 1;
sum[i + 1] -= 1;
ans++;
}
}
for (int i = 1; i<= n; i++)
sum[i] += sum[i - 1];
cn = suf[r + 1];
for (int i = r; i >= l; i--)
{
if ( sum[i] + suf[i] < cn)
ans++, cn = suf[i];
}
printf("%d\n", ans);
// system("pause");
}
}
Compilation message
election.cpp:11:10: fatal error: conio.h: No such file or directory
#include <conio.h>
^~~~~~~~~
compilation terminated.