Hello. In yesterday's contest i was trying to solve its C problem but didn't finish it, so i have tried it again today but after implementing the idea that i had, i get time limit exceeded on test 3 (even though i implemented it with binary search, at least i think so). So here is what i tried: I reversed the sequence and then for every subsequence starting from index i and ending at size of vector for its maximal cost took maximal size of subsequences subsequence where its all members are >= of theirs indices+1-i; 196127370 Is the observation bad or did i implement it wrong, or both. Thanks for help.
In your binarys function, you're passing a copy of your vector which will significantly take a lot of time. Pass the address of the vector to your function instead.
$$$int binarys(vector<int>&v, int l, int x){ ... }$$$