#include using namespace std; vector > DP; int n, m, k, r; vector L; vector > C; long long f(int seg, int l){ if(seg == n) return (l == 0 ? 0 : LLONG_MAX/2); long long& x = DP[seg][l]; if(x >= 0) return x; x = LLONG_MAX/2; for(int i=0;i> n >> m >> k >> r; L.resize(n); for(auto& x : L) cin >> x; C.resize(n-1); for(auto& x : C) cin >> x.first >> x.second; C.emplace_back(0,0); // Make life easier... DP.assign(n+1, vector(m+1, -1)); cout << f(0,0) << endl; }