Advertisement
TimxAG

Untitled

Nov 15th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. struct first
  5. {
  6. long long time;
  7. long long cost;
  8. } ;
  9. bool cmp(first one, first sec)
  10. {
  11. return one.time>sec.time;
  12. }
  13. int main()
  14. {
  15. long long x,m,s,n,m1,minn,min2=2*1000000000,minnn=2*1000000000,i,k,q,qq;
  16. cin >> n >> m >> m1;
  17. cin >> x >> s;long long b[m1],b1[m1]; int f=2;first a[m];
  18. for (i=0;i<m;i++)
  19. cin >> a[i].time;
  20. for (i=0;i<m;i++)
  21. {
  22. cin >> a[i].cost;
  23. if ((a[i].time<min2) && (a[i].cost<=s))
  24. { f=3;min2=a[i].time;}
  25. }
  26. sort(a,a+m,cmp);
  27. for (i=0;i<m1;i++)
  28. cin >> b[i];
  29. for (i=0;i<m1;i++)
  30. {
  31. cin >> b1[i];if (b1[i]>s) continue;
  32. /* minn=2*1000000000;f=0;
  33. for (q=0;q<m;q++)
  34. if ((a[q]<minn) && (a1[q]<=(s-b1[i])) )
  35. {
  36. minn=a[q];qq=(n-b[i])*a[q];f=1;
  37. // cout << minn << " " << a[q] << " " << b[i] << " " << qq << endl;
  38. }
  39. if (f==0) qq=((n-b[i])*x);
  40. if (qq<minnn) minnn=qq; */
  41. f=0;q=0;
  42. // while ((a[q].cost<(s-b1[i]) && (f==0)))
  43. while((f==0) || (q<m))
  44. {
  45. if (a[q].cost<(s-b1[i]))
  46. {
  47.  
  48. minn=a[q].time;qq=(n-b[i])*a[q].time;f=1;
  49. }
  50. // cout << minn << " " << a[q].time << " " << b[i] << " " << qq << endl;
  51. q++;
  52. if (qq<minnn) minnn=qq;
  53. }
  54. if (q==0) qq=((n-b[i])*x);
  55.  
  56. }
  57. if (f==3) minnn=min2*n;
  58. if (f==2) minnn=x*n;
  59. cout << minnn;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement