Enumeration of each lamp, and then find the minimum price that the lamp
Greedy strategy: the lamp is placed to the right from zero, if the end of the tube is not placed the node, then back to find the nearest node can be placed a lamp, the lamp is placed where
Therefore, the first preprocessing each lamp can not be placed nearest the node corresponding to the node lamp can be placed, i.e., to be able to find the forward automatically subscript
using namespace std; int a[maxn]; int b[maxn]; int n,m,k; LL work(int ins) { LL ans=0; int id=0; while(id<=n) { if(id+ins>=n) { ans++; break; } id=a[id+ins]; ans++; } return ans*b[ins]; } int main() { while(~scanf("%d%d%d",&n,&m,&k)) { lan(a,0); lan(b,0); For(i,1,m) { int tem; scanf("%d",&tem); a[tem]=1; } For(i,1,k) { int tem; scanf("%d",&b[i]); } if(a[0]==1) { printf("-1\n"); continue; } int id=0; int curlen=0; int maxlen=0; For(i,1,n) { if(a[i]==0) { a[i]=i; id=i; } else { a[i]=id; } maxlen=max(maxlen,i-a[i]); } if(maxlen>=k) { printf("-1\n"); continue; } LL ans=1LL<<60; For(i,maxlen+1,k) { ans=min(ans,work(i)); } printf("%lld\n",ans); } return 0; }