(あとで)
class PiecewiseLinearFunction { public: int maximumSolutions(vector <int> Y) { REP(i, Y.size()) Y[i]*=2; int offset[] = {-1, 0, 1}; ll ans = 0; REP(i, Y.size()) { REP(oi, 3) { ll y = Y[i]+offset[oi]; ll cnt = 0; REP(i, Y.size()) if(Y[i]==y) cnt++; REP(i, Y.size()-1) { if(Y[i]==Y[i+1]) return -1; if(min(Y[i], Y[i+1])<y && y<max(Y[i], Y[i+1])) cnt++; } ans = max(ans, cnt); } } return ans; } };