#include "locmin.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAXN = 505;
int done[MAXN], m;

ll query(int x)
{
    if (done[x] != -1)
        return done[x];
    done[x] = value(1, x);
    return done[x];
}

std::pair<int, int> find_locmin_point(int n, int m)
{
    fill(done, done + MAXN, -1);
    done[0] = INT_MIN, done[m + 1] = INT_MAX;

    int low = 1, high = m;
    while (low <= high)
    {
        int mid = (low + high) / 2;
        if ((query(mid) < query(mid + 1)) and (query(mid) < query(mid - 1)))
            return {1, mid};
        if (query(mid) < query(mid + 1))
            high = mid - 1;
        if (query(mid) > query(mid + 1))
            low = mid + 1;
    }

    return {1, low};
}
