Submission #61486

# Submission time Handle Problem Language Result Execution time Memory
61486 2018-07-26T05:24:31 Z 김세빈(#1779) Election (BOI18_election) C++11
0 / 100
16 ms 376 KB
#include <bits/stdc++.h>

using namespace std;

char str[505050];
int L[505050], R[505050];
int n;

int main()
{
	int q, i, l, r, k, s;
	
	scanf("%d%s%d", &n, str, &q);
	
	for(; q--; ){
		scanf("%d%d", &l, &r);
		
		k = s = 0;
		
		for(i=l; i<r; i++){
			if(str[i-1] == 'C') s ++;
			else s --;
			
			L[i] = s;
			if(i > l) L[i] = min(L[i], L[i-1]);
		}
		
		s = 0;
		
		for(i=r; i>l; i--){
			if(str[i-1] == 'C') s ++;
			else s --;
			
			R[i] = s;
			if(i < r) R[i] = min(R[i], R[i+1]);
		}
		
		for(i=l; i<r; i++){
			k = max(k, max(0, -L[i]) + max(0, -R[i+1]));
		}
		
		printf("%d\n", k);
	}
	
	return 0;
}

Compilation message

election.cpp: In function 'int main()':
election.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%s%d", &n, str, &q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
election.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &l, &r);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -