#include using pll = std::pair; std::vector AB; int N, K; // 引数より小さい物first); return 0; } bool lower_fewer(long long num) { long long sum{}; for (auto& e: AB) { if (num <= e.first) continue; if (e.second < num) sum += e.second + 1 - e.first; else sum += num - e.first; } return sum < K; } bool exist(long long candidate) { for (auto& e: AB) if (e.first <= candidate && candidate <= e.second) return true; return false; }