#include <iostream>
using namespace std;
int ternarySearch(int arr[], int n, int x) {
int left = 0, right = n - 1;
while (left <= right) {
int mid1 = left + (right - left) / 3;
int mid2 = right - (right - left) / 3;
if (arr[mid1] == x) return mid1;
if (arr[mid2] == x) return mid2;
if (x < arr[mid1])
right = mid1 - 1; // Tìm bên trái
else if (x > arr[mid2])
left = mid2 + 1; // Tìm bên phải
else
left = mid1 + 1, right = mid2 - 1; // Tìm ở giữa
}
return -1; // Không tìm thấy
}
int main() {
int n,target;
cin >> n >> target;
int a[n];
for(int i = 0;i<n;i++){
cin >> a[i];
}
int result = ternarySearch(a, n, target);
if(result==1) cout << "FOUND";
else cout << "NOT FOUND";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IHRlcm5hcnlTZWFyY2goaW50IGFycltdLCBpbnQgbiwgaW50IHgpIHsKICAgIGludCBsZWZ0ID0gMCwgcmlnaHQgPSBuIC0gMTsKICAgIAogICAgd2hpbGUgKGxlZnQgPD0gcmlnaHQpIHsKICAgICAgICBpbnQgbWlkMSA9IGxlZnQgKyAocmlnaHQgLSBsZWZ0KSAvIDM7CiAgICAgICAgaW50IG1pZDIgPSByaWdodCAtIChyaWdodCAtIGxlZnQpIC8gMzsKCiAgICAgICAgaWYgKGFyclttaWQxXSA9PSB4KSByZXR1cm4gbWlkMTsKICAgICAgICBpZiAoYXJyW21pZDJdID09IHgpIHJldHVybiBtaWQyOwoKICAgICAgICBpZiAoeCA8IGFyclttaWQxXSkKICAgICAgICAgICAgcmlnaHQgPSBtaWQxIC0gMTsgIC8vIFTDrG0gYsOqbiB0csOhaQogICAgICAgIGVsc2UgaWYgKHggPiBhcnJbbWlkMl0pCiAgICAgICAgICAgIGxlZnQgPSBtaWQyICsgMTsgICAvLyBUw6xtIGLDqm4gcGjhuqNpCiAgICAgICAgZWxzZQogICAgICAgICAgICBsZWZ0ID0gbWlkMSArIDEsIHJpZ2h0ID0gbWlkMiAt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