답안 #84505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
84505 2018-11-15T18:39:27 Z Pajaraja Election (BOI18_election) C++17
28 / 100
3000 ms 2000 KB
#include <bits/stdc++.h>
#define MAXN 500007
using namespace std;
string s;
char c[MAXN];
int val[MAXN],sol[MAXN],a[MAXN];
int main()
{
	int n,q;
	cin>>n>>s>>q;
	for(int i=0;i<q;i++)
	{
		int l,r;
		cin>>l>>r;
		int m=r-l+1,sum=0,t=0,mi=0;
		for(int i=l;i<=r;i++) a[i-l]=s[i-1]=='T'?-1:1;
		for(int i=0;i<m;i++) 
		{
			sum+=a[i];
			if(sum<0) {sum=0; a[i]=0; t++;}
		}
		sum=0;
		for(int i=m-1;i>=0;i--) 
		{
			sum+=a[i];
			mi=min(mi,sum);
		}
		cout<<t-mi<<endl;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 376 KB Output is correct
2 Correct 9 ms 456 KB Output is correct
3 Correct 14 ms 456 KB Output is correct
4 Correct 10 ms 472 KB Output is correct
5 Correct 10 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 376 KB Output is correct
2 Correct 9 ms 456 KB Output is correct
3 Correct 14 ms 456 KB Output is correct
4 Correct 10 ms 472 KB Output is correct
5 Correct 10 ms 540 KB Output is correct
6 Execution timed out 3044 ms 2000 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 376 KB Output is correct
2 Correct 9 ms 456 KB Output is correct
3 Correct 14 ms 456 KB Output is correct
4 Correct 10 ms 472 KB Output is correct
5 Correct 10 ms 540 KB Output is correct
6 Execution timed out 3044 ms 2000 KB Time limit exceeded
7 Halted 0 ms 0 KB -