SHARE
TWEET

Untitled

a guest Jun 13th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. #define forn(i, n) for (int i = 0; i < int(n); i++)
  4.  
  5. using namespace std;
  6.  
  7. const int INF = 1e9;
  8. const long long INF64 = 1e18;
  9. const int N = 1000 * 1000 + 13;
  10.  
  11. int n, m, k;
  12. int s[N], a[N];
  13. bool pos[N];
  14. int dp[N];
  15.  
  16. int get(int l){
  17.     forn(i, n + 1) dp[i] = INF;
  18.     dp[0] = 0;
  19.     forn(i, n){
  20.         if (!pos[i]) continue;
  21.         for (int j = i + 1; j <= min(n, i + l); ++j)
  22.             dp[j] = min(dp[j], dp[i] + 1);
  23.     }
  24.     return dp[n];
  25. }
  26.  
  27. int main() {
  28.     scanf("%d%d%d", &n, &m, &k);
  29.     forn(i, m) scanf("%d", &s[i]);
  30.     forn(i, k) scanf("%d", &a[i]);
  31.     forn(i, n + 1) pos[i] = true;
  32.     forn(i, m) pos[s[i]] = false;
  33.     long long ans = INF64;
  34.     forn(i, k){
  35.         long long t = get(i + 1);
  36.         if (t != INF)
  37.             ans = min(ans, a[i] * t);
  38.     }
  39.     printf("%lld\n", ans == INF64 ? -1 : ans);
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top