#include "locmin.h"
#include <algorithm>

using namespace std;

pair<int, int> find_locmin_point(int N, int M) {
    int l = 1, r = M;
    while (r - l > 0) {
        int m1 = (l + r) / 2;
        int m2 = (l + r) / 2 + 1;

        if (value(1, m1) <= value(1, m2)) {
            r = m1;
        }
        else {
            l = m2;
        }
    }

    return { 1, l };
}
