Submission #60919

# Submission time Handle Problem Language Result Execution time Memory
60919 2018-07-25T01:38:53 Z ksun48 Homecoming (BOI18_homecoming) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int n;
int q;
string s;
vector<int> psums;
int max_psum(int a, int b){
	int z = 0;
	for(int i = a; i <= b; i++){
		for(int j = i; j <= b; j++){
			z = max(psums[j] - psums[i], z);
		}
	}
	return z;
}
int main(){
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n >> s >> q;
	psums.push_back(0);
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'C'){
			psums.push_back(psums[psums.size() - 1] + 1);
		} else {
			psums.push_back(psums[psums.size() - 1] - 1);
		}
	}
	for(int i = 0; i < q; i++){
		int l, r;
		cin >> l >> r;
		l--; r--;
		r++;
		int a = max_psum(l, r);
		cout << a - (psums[r] - psums[l]) << '\n';
	}
}

Compilation message

homecoming.cpp: In function 'int main()':
homecoming.cpp:22:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < s.size(); i++){
                 ~~^~~~~~~~~~
/tmp/cchiET3J.o: In function `main':
homecoming.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccL5hl9c.o:grader.cpp:(.text.startup+0x0): first defined here
/tmp/ccL5hl9c.o: In function `main':
grader.cpp:(.text.startup+0xff): undefined reference to `solve(int, int, int*, int*)'
collect2: error: ld returned 1 exit status