| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 405147 | tsaraf | Election (BOI18_election) | C++17 | 3 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
const int N = 500 + 3;
int n, Q;
string s;
void solve(){
cin >> n >> s >> Q;
while(Q--){
int L, R; cin >> L >> R; --L; --R;
bool vis[n]; memset(vis, false, sizeof(vis));
int sum = 0, ans = 0;;
for(int i = L; i <= R; ++i){
int vote = (s[i] == 'C' ? +1 : -1);
if(sum + vote < 0){
vis[i] = true;
++ans;
} else {
sum += vote;
}
}
sum = 0;
for(int i = R; i >= L; --i){
if(!vis[i]){
int vote = (s[i] == 'C' ? +1 : -1);
if(sum + vote < 0){
vis[i] = true;
++ans;
} else {
sum += vote;
}
}
}
cout << ans << '\n';
}
}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false); cin.tie(0);
int t = 1;
// cin >> t;
for(int i = 1; i <= t; i++){
// cout << "Case #" << i << ": ";
solve();
}
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... | ||||
