Help me in solving TRIPLETMIN problem How to find all triple in o(n)

My issue

My code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
    int n;cin>>n;
int main() {
	// your code goes here
	int t;cin>>t;
	return 0;

Problem Link: TRIPLETMIN Problem - CodeChef

It can be done in O(nlogn) using binary search and some prefix precomputation but in O(n) i don’t think its possible.