区間の両端だけを気にすればいい。
class EelAndRabbit { public: int getmax(vector <int> l, vector <int> t) { const int N = l.size(); vector<double> T; int mx = 1; for (int i = 0; i < N; ++i) { for (int j = i + 1; j < N; ++j) { vector<double> cand; cand.push_back(t[i]); cand.push_back(t[i] + l[i]); cand.push_back(t[j]); cand.push_back(t[j] + l[j]); for (int a = 0; a < cand.size(); ++a) { for (int b = 0; b < cand.size(); ++b) { set<int> vis; for (int k = 0; k < N; ++k) { if (t[k] + l[k] >= cand[a] && cand[a] >= t[k]) { vis.insert(k); } if (t[k] + l[k] >= cand[b] && cand[b] >= t[k]) { vis.insert(k); } } mx = max(mx, (int)vis.size()); } } } } return mx; }