#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; bool check(const vector<pair<int, int>>& friends, ll mid, ll k) { int n = friends.size(); ll total_joy = 0; int left = 0; for (int right = 0; righ...