# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
565632 | Rifal | Election (BOI18_election) | C++14 | 15 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <fstream>
#define endl '\n'
#define mod 32768
#define INF 100000000000000
//#define ll long long
//#define cin fin
//#define cout fout
using namespace std;
//ofstream fout("convention.out");
//ifstream fin("convention.in");
int main()
{
int n, q;
string s;
cin >> n >> s >> q;
while(q--)
{
int l, r;
cin >> l >> r;
long long ans = INF;
long long sum = 0;
int tt = 0, cc = 0;
for(int i = l-1; i < r; i++)
{
if(s[i] == 'T')
{
if(cc > 0)
cc--;
else
sum++;
}
else
{
cc++;
}
}
ans = min(sum,ans);
tt = 0, cc = 0, sum = 0;
for(int i = r-1; i >= l-1; i--)
{
if(s[i] == 'T')
{
if(cc > 0)
cc--;
else
sum++;
}
else
{
cc++;
}
}
cout << max(ans,sum) << endl;
}
return 0;
}
컴파일 시 표준 에러 (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... |