이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
void solve(int n)
{
	int arr[2][n + 50], res[n + 50];
	res[1] = 0;
	for(int i=1; i <= n; i ++)
	{
		if(i + 1 <= n) arr[0][i] = query(i, i + 1);
		if(i + 1 <= n && i - 1 >= 1) arr[1][i] = query(i - 1, i + 1);
	}
	res[2] = arr[0][1];
	int d[2] = {1, -1}, now = false;
	for(int i=3; i <= n; i ++)
	{
		if(arr[0][i - 2] + arr[0][i - 1] != arr[1][i - 1]) now = !now;
		res[i] = res[i - 1] + arr[0][i - 1] * d[now];
	}
	int mx = 1, mi = 1;
	for(int i=1; i <= n; i ++)
	{
		if(res[i] > res[mx]) mx = i;
		if(res[i] < res[mi]) mi = i;
	}
	if(mx < mi)
	{
		for(int i=1; i <= n; i ++)
			res[i] *= -1;
	}
	mx = 0;
	for(int i=1; i <= n; i ++)
		mx = max(mx, res[i]);
	// for(int i=1; i <= n; i ++)
	// 	cout << res[i] + n - mx << ' ';
	// cout << '\n';
	for(int i=1; i <= n; i ++)
		answer(i, res[i] + n - mx);
}
// static const int N_MAX = 5000;
// static const int Q_MAX = 10000;
// static int N;
// static int A[N_MAX];
// static bool used[N_MAX];
// static int query_c;
// static int answer_c;
// // int query(int s, int t) {
// // 	if(query_c >= Q_MAX) {
// // 		printf("Wrong Answer\n");
// // 		exit(0);
// // 	}
// // 	query_c++;
// // 	if(!(1 <= s && s <= t && t <= N)) {
// // 		printf("Wrong Answer\n");
// // 		exit(0);
// // 	}
// // 	int mx = 0, mn = N + 1;
// // 	for(int i = s - 1; i < t; i++) {
// // 		if(mx < A[i]) {
// // 			mx = A[i];
// // 		}
// // 		if(mn > A[i]) {
// // 			mn = A[i];
// // 		}
// // 	}
// // 	return mx - mn;
// // }
// // // void answer(int i, int a) {
// // // 	answer_c++;
// // // 	if(!(1 <= i && i <= N)) {
// // // 		printf("Wrong Answer\n");
// // // 		exit(0);
// // // 	}
// // // 	if(!(1 <= a && a <= N)) {
// // // 		printf("Wrong Answer\n");
// // // 		exit(0);
// // // 	}
// // // 	if(used[i - 1]) {
// // // 		printf("Wrong Answer\n");
// // // 		exit(0);
// // // 	}
// // // 	if(a != A[i - 1]) {
// // // 		printf("Wrong Answer\n");
// // // 		exit(0);
// // // 	}
// // // 	used[i - 1] = true;
// // // }
// // // int main() {
// // // 	query_c = 0;
// // // 	answer_c = 0;
// // // 	if(scanf("%d", &N) != 1) {
// // // 		fprintf(stderr, "Error while reading input\n");
// // // 		exit(1);
// // // 	}
// // // 	for(int i = 0; i < N; i++) {
// // // 		if(scanf("%d", A + i) != 1) {
// // // 			fprintf(stderr, "Error while reading input\n");
// // // 			exit(1);
// // // 		}
// // // 		used[i] = false;
// // // 	}
// // // 	solve(N);
// // // 	if(!(answer_c == N)) {
// // // 		printf("Wrong Answer\n");
// // // 		exit(0);
// // // 	}
// // // 	printf("Accepted : %d\n", query_c);
// // // }
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |