#include <bits/stdc++.h> using namespace std; const int N = 70, M = 32010; // <value, value * priority> typedef pair<int, int> PII; #define x first #define y second int n, m; int f[M]; PII masters[N]; vector<PII> accessory[N]; int main(){ cin >> m >> n; ...