Submission #198581

# Submission time Handle Problem Language Result Execution time Memory
198581 2020-01-26T17:13:56 Z rKrPaN Xylophone (JOI18_xylophone) C++
Compilation error
0 ms 0 KB
#include "xylophone.h"

static int niz[5000];
int Q[5000][2];

void solve(int N) {

	for (int i = 1; i <= N-1; i++){
		Q[i][1] = query(i, i+1);
	}
	for (int i = 1; i <= N-2; i++){
		Q[i][2] = query(i, i+2);
	}
	
	niz[2] = Q[1][1];
	
	for (int i = 3; i <= N; i++){
		if (Q[i-2][2] == Q[i-2][1] + Q[i-1][1]){
			if (niz[i-2] < niz[i-1])niz[i] = niz[i-1] + Q[i-1][1];
			else niz[i] = niz[i-1] - Q[i-1][1];
		}
		
		if (Q[i-2][2] == max(Q[i-2][1], Q[i-1][1])){
			if (niz[i-2] < niz[i-1])niz[i] = niz[i-1] - Q[i-1][1];
			else niz[i] = niz[i-1] + Q[i-1][1];
		}
	}
	
	int mn = 5010;
	int mx = -5010;
	int plus;
	int inv = 1;
	
	for (int i = 1; i <= N; i++){
		if (niz[i] < mn)mn = niz[i];
		if (niz[i] > mx)mx = niz[i];
	}
	plus = -mn+1;
	
	for (int i = 1; i <= N; i++){
		if (niz[i] == mn)break;
		if (niz[i] == mn + N-1){
			inv = -1;
			plus = mx+1;
			break;
		}
	}
	
	for (int i = 1; i <= N; i++){
		answer (i, inv*niz[i] + plus);
	}

}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:23:20: error: 'max' was not declared in this scope
   if (Q[i-2][2] == max(Q[i-2][1], Q[i-1][1])){
                    ^~~