vector<Point> hull; for (int step = 1; step <= N - 1; ++step) { hull.push_back(Point(step, step_mndis[step])); } hull = make_convex_hull(hull, true); ll ans = 0; for (int i = 0; i < SZ(hull); ++i) { auto [step,dummy] = hull[i]; if (i == 0) { ans += step_sp_cnt[step]; ans %= mod; continue; } // 我们只要下凸包 if (dummy > hull[i - 1].y) { break; } ans += step_sp_cnt[step]; ans %= mod; }