답안 #759742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
759742 2023-06-16T18:01:50 Z vjudge1 Election (BOI18_election) C++17
28 / 100
3000 ms 1388 KB
///YOU WILL MAKE IT
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
void solve(){
   int ta;cin>>ta;
   string s;cin>>s;
   int q;cin>>q;
   while(q--){
    int l,r;cin>>l>>r;
    l--;
    r--;
    string temp=s;
    int c=0,t=0,ans=0;
    for(int i=l;i<=r;i++){
        t+=(temp[i]=='T');
        c+=(temp[i]=='C');
        if(t>c){
            temp[i]='#';
            ans++;
            t--;
        }
    }
    c=0;
    t=0;
    for(int i=r;i>=l;i--){
        t+=(temp[i]=='T');
        c+=(temp[i]=='C');
        if(t>c){
            temp[i]='#';
            ans++;
            t--;
        }
    }
    cout<<ans<<endl;
   }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 212 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 6 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 212 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 6 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Execution timed out 3050 ms 1388 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 212 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 6 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Execution timed out 3050 ms 1388 KB Time limit exceeded
7 Halted 0 ms 0 KB -