# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1150693 | mingga | Xylophone (JOI18_xylophone) | C++20 | 26 ms | 432 KiB |
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
static int a[5005];
void solve(int n) {
a[1] = 0;
a[2] = query(1, 2);
for(int i = 3; i <= n; i++) {
int x1 = a[i - 1] - a[i - 2];
int x2 = query(i - 1, i);
int x3 = query(i - 2, i);
int sign = (x1 > 0 ? 1 : -1);
x1 = abs(x1);
if(x1 + x2 == x3) {
a[i] = a[i - 1] + x2 * sign;
} else {
a[i] = a[i - 1] - x2 * sign;
}
}
int mxid = 1, mnid = 1;
for(int i = 2; i <= n; i++) {
if(a[i] > a[mxid]) mxid = i;
if(a[i] < a[mnid]) mnid = i;
}
if(mxid < mnid) {
for(int i = 1; i <= n; i++) a[i] = -a[i];
swap(mnid, mxid);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |