Source Code

            int p = lower_bound(vals.begin() , vals.end() , x) - vals.begin();
            if(p == (int)vals.size()){
                ans.push_back(-1);
            }
            else{
                ans.push_back(suffix[p]);
            }
        }
        for(int x : ans){
            cout << x << " ";
        }
        cout << '\n';
    }
    return 0;
}
Copy
Easy challenge? Greedious
GNU G++17
0 ms
0 KB
Compilation Error