답안 #73837

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73837 2018-08-29T06:22:14 Z jiaqing23 Election (BOI18_election) C++14
0 / 100
12 ms 380 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
typedef pair<int,pair<int,int> > tri;

int n, q;
string s;

int maxpre(int l, int r){
    int tem = 0, now = 0;
    for(int i = l; i <= r; i++){
        if(s[i] == 'C') now--;
        else now++;
        tem = max(tem, now);
    }
    return tem;
}

int maxsuf(int l, int r){
    int tem = 0, now = 0;
    for(int i = r; i >= l; i--){
        if(s[i] == 'C') now--;
        else now++;
        tem = max(tem, now);
    }
    return tem;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> s >> q;
    while(q--){
        int l, r;
        cin >> l >> r;
        l--; r--;
        int ans = max(maxpre(l,r),maxsuf(l,r));
        if(ans < 0) ans = 0;
        cout << ans << endl;
    }
	return 0;
} 
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -