Submission #61462

# Submission time Handle Problem Language Result Execution time Memory
61462 2018-07-26T04:45:46 Z 김세빈(#1779) Election (BOI18_election) C++11
0 / 100
5 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;
	
	scanf("%d%s%d", &n, str, &q);
	
	for(i=1; i<=n; i++){
		if(str[i-1] == 'C') L[i] = L[i-1] - 1;
		else L[i] = L[i-1] + 1;
	}
	
	for(i=n; i>=1; i--){
		if(str[i-1] == 'C') R[i] = R[i+1] - 1;
		else R[i] = R[i+1] + 1;
	}
	
	for(; q--; ){
		scanf("%d%d", &l, &r);
		
		k = 0;
		
		for(i=l; i<r; i++){
			k = max(k, max(0, L[i] - L[l-1]) + max(0, R[i+1] - R[r+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:26: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 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -