Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define st first
  3. #define nd second
  4. #define N 100005
  5. #define pb push_back
  6. using namespace std;
  7. typedef long long ll;
  8. void fast()
  9. {
  10. ios_base::sync_with_stdio(false);
  11. cin.tie();
  12. }
  13. ll books[N], i, j, n, m, b, l, d;
  14. bool used[N];
  15. vector<ll> orderlb;
  16. bool comp(ll a, ll b)
  17. {
  18. return books[a]>books[b];
  19. }
  20. struct library
  21. {
  22. vector<ll> v;
  23. ll sgup, nrb;
  24. }lb[N];
  25. void aranjeaza_librarii()
  26. {
  27. ll curr=0;
  28. for(int i=0;i<=l&&curr+lb[i].sgup<=d;++i)
  29. {
  30. orderlb.pb(i);
  31. curr+=lb[i].sgup;
  32. }
  33.  
  34. }
  35. int main()
  36. {
  37. fast();
  38. freopen("input","r",stdin);
  39. freopen("ouput2","w",stdout);
  40. cin>>b>>l>>d;
  41. for(i=0;i<b;++i)
  42. cin>>books[i];
  43. for(i=0;i<l;++i)
  44. {
  45. cin>>n>>lb[i].sgup>>lb[i].nrb;
  46. for(j=0;j<n;++j)
  47. {
  48. ll x;
  49. cin>>x;
  50. lb[i].v.pb(x);
  51. }
  52. sort(lb[i].v.begin(),lb[i].v.end(),comp);
  53. }
  54. aranjeaza_librarii();
  55. cout<<orderlb.size()<<'\n';
  56. for(auto x:orderlb)
  57. {
  58. ll timp=d-lb[i].sgup;
  59. j=0;
  60. vector<ll> ordb;
  61. for(i=0;i<timp&&j<lb[i].v.size();++i)
  62. {
  63. for(int ind=1;ind<=lb[i].nrb&&j<lb[i].v.size();++ind,++j)
  64. {
  65. if(used[lb[i].v[j]])
  66. {
  67. --ind;
  68. ++j;
  69. continue;
  70. }
  71. ordb.pb(lb[i].v[j]);
  72. used[lb[i].v[j]]=1;
  73. }
  74. }
  75. cout<<orderlb[i]<<' '<<ordb.size()<<'\n';
  76. for(auto i:ordb)
  77. cout<<i<<' ';
  78. cout<<'\n';
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement