# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1173950 | 12345678 | Swap (BOI16_swap) | C++20 | 11 ms | 12160 KiB |
#include <bits/stdc++.h>
using namespace std;
const int nx=2e5+5;
int n, a[nx], lvl[nx];
map<int, int> dp[nx];
int getdp(int u, int vl)
{
if (dp[u].find(vl)!=dp[u].end()) return dp[u][vl];
if (2*u>n) return dp[u][vl]=u;
if (2*u==n)
{
if (a[u]<a[2*u]) return dp[u][vl]=u;
else return dp[u][vl]=2*u;
}
int mn=min({vl, a[2*u], a[2*u+1]});
if (vl==mn) return dp[u][vl]=u;
else if (a[2*u]==mn) return dp[u][vl]=getdp(2*u, vl);
else
{
if (vl<a[2*u])
{
if (getdp(2*u, vl)<=getdp(2*u+1, vl)) return dp[u][vl]=getdp(2*u, vl);
else return dp[u][vl]=getdp(2*u+1, vl);
}
else
{
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |