# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
96269 | 2019-02-07T16:59:30 Z | KLPP | Election (BOI18_election) | C++14 | 3000 ms | 1488 KB |
#include<bits/stdc++.h> using namespace std; int main(){ int n; scanf("%d",&n); char arr[n]; string s; cin>>s; for(int i=0;i<n;i++)arr[i]=s.at(i); int q; scanf("%d",&q); for(int i=0;i<q;i++){ int s,e; scanf("%d %d",&s,&e); s--;e--; bool B[e-s+1]; for(int j=0;j<=e-s;j++)B[j]=false; int diff=0; for(int j=s;j<=e;j++){ //cout<<diff<<endl; if(arr[j]=='C')diff++; else diff--; if(diff<0){ diff=0; B[j-s]=true; }//cout<<diff<<endl; }diff=0; for(int j=e;j>=s;j--){ if(!B[j-s]){ if(arr[j]=='C')diff++; else diff--; } if(diff<0){ diff=0; B[j-s]=true; } } int ans=0; for(int j=s;j<=e;j++){ //cout<<B[j-s]; ans+=B[j-s]; }//cout<<endl; printf("%d\n",ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 376 KB | Output is correct |
2 | Correct | 9 ms | 376 KB | Output is correct |
3 | Correct | 7 ms | 376 KB | Output is correct |
4 | Correct | 7 ms | 376 KB | Output is correct |
5 | Correct | 6 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 376 KB | Output is correct |
2 | Correct | 9 ms | 376 KB | Output is correct |
3 | Correct | 7 ms | 376 KB | Output is correct |
4 | Correct | 7 ms | 376 KB | Output is correct |
5 | Correct | 6 ms | 376 KB | Output is correct |
6 | Execution timed out | 3047 ms | 1488 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 376 KB | Output is correct |
2 | Correct | 9 ms | 376 KB | Output is correct |
3 | Correct | 7 ms | 376 KB | Output is correct |
4 | Correct | 7 ms | 376 KB | Output is correct |
5 | Correct | 6 ms | 376 KB | Output is correct |
6 | Execution timed out | 3047 ms | 1488 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |