#include #include using namespace std; using namespace atcoder; using ll=long long; int main() { int n, k; cin>>n>>k; mcf_graph g(n); ll a[50050]; const ll geta=1e9; for(int i=0; i>a[i]; int m; cin>>m; for(int j=0; j>b; b--; g.add_edge(b, i, 1, a[b]-a[i]+geta*(i-b)); } } for(int i=0; i