#include #include using namespace std; int N,K; int A[1<<17]; main() { cin>>N>>K; atcoder::mcf_graphP(N+1); const long off=1e9; for(int i=1;i<=N;i++) { int M; P.add_edge(i-1,i,K,off); cin>>A[i]>>M; for(int j=0;j>u; P.add_edge(u,i,1,A[u]-A[i]+(i-u)*off); } } cout<