Advertisement
Dorijanko

Untitled

May 20th, 2018
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int l,n,m[101],a;
  6. int pr1[101][101];
  7. int h[101][101],mi[101][101],s[101][101];
  8. int pr2[101][101];
  9. int wh[101];
  10. int re[101];
  11. int mgc;
  12.  
  13. void rek(int i,int time,int gemcost)
  14. {
  15. //cout<<i<<' '<<time<<' '<<gemcost<<endl;
  16. if (time>l) return;
  17. if (i==n)
  18. {
  19. if (gemcost<mgc)
  20. {
  21. for (int j=0;j<n;++j) re[j]=wh[j];
  22. mgc=gemcost;
  23. }
  24. }
  25. else
  26. {
  27. for (int j=0;j<m[i];++j)
  28. {
  29. wh[i]=j;
  30. rek(i+1,time+pr1[i][j],gemcost+pr2[i][j]);
  31. if (i==0)
  32. {
  33. cout<<"Step "<<j<<" complete."<<endl;
  34. }
  35. if (i==1)
  36. {
  37. cout<<"Step "<<i<<j<<" complete."<<endl;
  38. }
  39. if (i==2)
  40. {
  41. cout<<"Step "<<i<<j<<" complete."<<endl;
  42. }
  43. }
  44. }
  45. }
  46.  
  47. int main()
  48. {
  49. std::ios_base::sync_with_stdio(false);
  50. ifstream fin("progressive.txt");
  51. ofstream fout("progressive.out");
  52. fin>>l>>a;
  53. fin>>n;
  54. l*=1440;
  55. l+=a*60;
  56. for (int i=0;i<n;++i)
  57. {
  58. fin>>m[i];
  59. for (int j=0;j<m[i];++j)
  60. {
  61. fin>>h[i][j]>>mi[i][j]>>s[i][j]>>pr2[i][j];
  62. mi[i][j]+=s[i][j]/60;
  63. s[i][j]%=60;
  64. h[i][j]+=mi[i][j]/24;
  65. mi[i][j]%=24;
  66. pr1[i][j]=h[i][j]*1440+mi[i][j]*60+s[i][j];
  67. }
  68. }
  69. mgc=10101;
  70. rek(0,0,0);
  71. for (int i=0;i<n;++i)
  72. {
  73. fout<<"On quest "<<i+1<<", use "<<pr2[i][re[i]]<<" gems at "<<h[i][re[i]]<<" days, "<<mi[i][re[i]]<<" hours and "<<s[i][re[i]]<<" minutes."<<endl;
  74. }
  75. fout<<"Total gem cost: "<<mgc<<" gems."<<endl;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement