# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1089810 | 2024-09-17T07:46:40 Z | lucri | Election (BOI18_election) | C++17 | 3000 ms | 1092 KB |
#include <bits/stdc++.h> using namespace std; char a[500010]; bool e[500010]; int n,q,x,y; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>a+1>>q; while(q--) { cin>>x>>y; int sum=0; for(int i=x;i<=y;++i) { if(a[i]=='C') ++sum; else --sum; if(sum>=0) e[i]=true; else { e[i]=false; ++sum; } } sum=0; int ans=0; for(int i=y;i>=x;--i) { if(e[i]==false) { ++ans; continue; } if(a[i]=='C') ++sum; else --sum; if(sum>=0) e[i]=true; else { ++ans; e[i]=false; ++sum; } } cout<<ans<<'\n'; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 348 KB | Output is correct |
2 | Correct | 4 ms | 500 KB | Output is correct |
3 | Correct | 3 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 500 KB | Output is correct |
5 | Correct | 3 ms | 500 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 348 KB | Output is correct |
2 | Correct | 4 ms | 500 KB | Output is correct |
3 | Correct | 3 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 500 KB | Output is correct |
5 | Correct | 3 ms | 500 KB | Output is correct |
6 | Execution timed out | 3063 ms | 1092 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 348 KB | Output is correct |
2 | Correct | 4 ms | 500 KB | Output is correct |
3 | Correct | 3 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 500 KB | Output is correct |
5 | Correct | 3 ms | 500 KB | Output is correct |
6 | Execution timed out | 3063 ms | 1092 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |