Submission #198150

# Submission time Handle Problem Language Result Execution time Memory
198150 2020-01-24T21:22:12 Z forelax Election (BOI18_election) C++14
28 / 100
3000 ms 2268 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i = 0 ; i < n ; i ++){
		char ch;cin>>ch;
		v[i]=ch=='C'?1:-1;
	}
	int q;
	cin>>q;
	vector<int> tm(n,-1);
	for(int i = 0,l,r ; i < q ; i ++){
		cin>>l>>r;l--;r--;
		int cnt=0,rez=0;
		for(int j = l ; j <= r ; j ++){
			cnt+=v[j];
			if(cnt==-1){
				cnt++;
				tm[j]=i;
				rez++;
			}
		}
		cnt=0;
		for(int j = r ; j >= l ; j --){
			if(tm[j]==i)continue;
			cnt+=v[j];
			if(cnt==-1){
				cnt++;
				tm[j]=i;
				rez++;
			}
		}
		cout<<rez<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 376 KB Output is correct
2 Correct 13 ms 504 KB Output is correct
3 Correct 12 ms 376 KB Output is correct
4 Correct 14 ms 376 KB Output is correct
5 Correct 12 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 376 KB Output is correct
2 Correct 13 ms 504 KB Output is correct
3 Correct 12 ms 376 KB Output is correct
4 Correct 14 ms 376 KB Output is correct
5 Correct 12 ms 376 KB Output is correct
6 Correct 2969 ms 2268 KB Output is correct
7 Execution timed out 3010 ms 1828 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 376 KB Output is correct
2 Correct 13 ms 504 KB Output is correct
3 Correct 12 ms 376 KB Output is correct
4 Correct 14 ms 376 KB Output is correct
5 Correct 12 ms 376 KB Output is correct
6 Correct 2969 ms 2268 KB Output is correct
7 Execution timed out 3010 ms 1828 KB Time limit exceeded
8 Halted 0 ms 0 KB -