Advertisement
Dorijanko

Maze

Oct 18th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. //You won't understand the input format anyway unless you read an example input which i'll send soon.
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. int n,k;
  7. bool uz[101];
  8. int nc[101],mo[101];
  9. int coi[101][101],key[101][101],cost[101][101],nu[101][101],de[101][101],dv[101][101],tr[101][101],pr[101][101];
  10. string h[101];
  11.  
  12. int main()
  13. {
  14. std::ios_base::sync_with_stdio(false);
  15. ifstream fin("maze.in");
  16. ofstream fout("maze.out");
  17. fin>>n;
  18. for (int i=0;i<n;++i) fin>>h[i];
  19. for (int i=0;i<n;++i)
  20. {
  21. fin>>nc[i];
  22. for (int j=0;j<n;++j) for (int k=0;k<4;++k) pr[k][j]=0;
  23. for (int j=0;j<nc[i];++j)
  24. {
  25. fin>>cost[i][j]>>coi[i][j]>>key[i][j];
  26. //coi[i][j]=0;
  27. nu[i][j+1]=nu[i][j]+cost[i][j]-coi[i][j];
  28. de[i][j+1]=de[i][j]+cost[i][j]-int(cost[i][j]*0.1)-coi[i][j];
  29. dv[i][j+1]=dv[i][j]+cost[i][j]-int(cost[i][j]*0.2)-coi[i][j];
  30. tr[i][j+1]=tr[i][j]+cost[i][j]-int(cost[i][j]*0.3)-coi[i][j];
  31. if (key[i][j])
  32. {
  33. --key[i][j];
  34. pr[0][key[i][j]]+=nu[i][j+1]-nu[i][0];
  35. pr[1][key[i][j]]+=de[i][j+1]-de[i][0];
  36. pr[2][key[i][j]]+=dv[i][j+1]-dv[i][0];
  37. pr[3][key[i][j]]+=tr[i][j+1]-tr[i][0];
  38. }
  39. }
  40. for (int j=0;j<4;++j)
  41. {
  42. for (int k=0;k<n;++k)
  43. {
  44. for (int l=0;l<k;++l) pr[j][k]=max(pr[j][k],pr[j][l]);
  45. }
  46. }
  47. for (int j=0;j<n;++j)
  48. {
  49. nu[j][0]+=pr[0][j];
  50. de[j][0]+=pr[1][j];
  51. dv[j][0]+=pr[2][j];
  52. tr[j][0]+=pr[3][j];
  53. if (j==2) cout<<i<<' '<<nu[j][0]<<endl;
  54. }
  55. }
  56. fout<<"No discount:"<<endl;
  57. for (int i=0;i<n;++i) fout<<"Mission "<<i+1<<'('<<h[i]<<") costs "<<nu[i][nc[i]]<<" maze coins with the keys, and "<<nu[i][nc[i]]-nu[i][0]<<" maze coins without the keys."<<endl;
  58. fout<<"10% discount:"<<endl;
  59. for (int i=0;i<n;++i) fout<<"Mission "<<i+1<<'('<<h[i]<<") costs "<<de[i][nc[i]]<<" maze coins with the keys, and "<<de[i][nc[i]]-de[i][0]<<" maze coins without the keys."<<endl;
  60. fout<<"20% discount:"<<endl;
  61. for (int i=0;i<n;++i) fout<<"Mission "<<i+1<<'('<<h[i]<<") costs "<<dv[i][nc[i]]<<" maze coins with the keys, and "<<dv[i][nc[i]]-dv[i][0]<<" maze coins without the keys."<<endl;
  62. fout<<"30% discount:"<<endl;
  63. for (int i=0;i<n;++i) fout<<"Mission "<<i+1<<'('<<h[i]<<") costs "<<tr[i][nc[i]]<<" maze coins with the keys, and "<<tr[i][nc[i]]-tr[i][0]<<" maze coins without the keys."<<endl;
  64. cout<<nu[2][0]<<endl;
  65. fout<<"0%: "<<nu[0][20]+nu[1][16]+nu[2][6]-nu[2][0]<<endl;
  66. fout<<"10%: "<<de[0][20]+de[1][16]+de[2][6]-de[2][0]<<endl;
  67. fout<<"20%: "<<dv[0][20]+dv[1][16]+dv[2][6]-dv[2][0]<<endl;
  68. fout<<"30%: "<<tr[0][20]+tr[1][16]+tr[2][6]-tr[2][0]<<endl;
  69. while (cin>>k)
  70. {
  71. for (int i=0;i<n;++i) uz[i]=0;
  72. int ma=0;
  73. for (int i=0;i<k;++i)
  74. {
  75. cin>>mo[i];
  76. --mo[i];
  77. ma=max(ma,mo[i]);
  78. uz[mo[i]]=1;
  79. }
  80. int amn=0,amd=0,amt=0,amf=0;
  81. for (int i=0;i<=ma;++i)
  82. {
  83. int dok=0;
  84. if (uz[i]) dok=nc[i];
  85. for (int j=0;j<nc[i];++j)
  86. {
  87. if (key[i][j]<=ma && key[i][j]>0) dok=max(dok,j+1);
  88. }
  89. amn+=nu[i][dok]-nu[i][0];
  90. amd+=de[i][dok]-de[i][0];
  91. amt+=dv[i][dok]-dv[i][0];
  92. amf+=tr[i][dok]-tr[i][0];
  93. cout<<dok<<endl;
  94. }
  95. for (int i=0;i<k-1;++i) fout<<h[mo[i]]<<'+';
  96. fout<<h[mo[k-1]]<<':'<<endl;
  97. fout<<"0%: "<<amn<<endl;
  98. fout<<"10%: "<<amd<<endl;
  99. fout<<"20%: "<<amt<<endl;
  100. fout<<"30%: "<<amf<<endl;
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement