Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- struct first
- {
- long long time;
- long long cost;
- } ;
- bool cmp(first one, first sec)
- {
- return one.time>sec.time;
- }
- int main()
- {
- long long x,m,s,n,m1,minn,min2=2*1000000000,minnn=2*1000000000,i,k,q,qq;
- cin >> n >> m >> m1;
- cin >> x >> s;long long b[m1],b1[m1]; int f=2;first a[m];
- for (i=0;i<m;i++)
- cin >> a[i].time;
- for (i=0;i<m;i++)
- {
- cin >> a[i].cost;
- if ((a[i].time<min2) && (a[i].cost<=s))
- { f=3;min2=a[i].time;}
- }
- sort(a,a+m,cmp);
- for (i=0;i<m1;i++)
- cin >> b[i];
- for (i=0;i<m1;i++)
- {
- cin >> b1[i];if (b1[i]>s) continue;
- /* minn=2*1000000000;f=0;
- for (q=0;q<m;q++)
- if ((a[q]<minn) && (a1[q]<=(s-b1[i])) )
- {
- minn=a[q];qq=(n-b[i])*a[q];f=1;
- // cout << minn << " " << a[q] << " " << b[i] << " " << qq << endl;
- }
- if (f==0) qq=((n-b[i])*x);
- if (qq<minnn) minnn=qq; */
- f=0;q=0;
- // while ((a[q].cost<(s-b1[i]) && (f==0)))
- while((f==0) || (q<m))
- {
- if (a[q].cost<(s-b1[i]))
- {
- minn=a[q].time;qq=(n-b[i])*a[q].time;f=1;
- }
- // cout << minn << " " << a[q].time << " " << b[i] << " " << qq << endl;
- q++;
- if (qq<minnn) minnn=qq;
- }
- if (q==0) qq=((n-b[i])*x);
- }
- if (f==3) minnn=min2*n;
- if (f==2) minnn=x*n;
- cout << minnn;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement