Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define st first
- #define nd second
- #define N 100005
- #define pb push_back
- using namespace std;
- typedef long long ll;
- void fast()
- {
- ios_base::sync_with_stdio(false);
- cin.tie();
- }
- ll books[N], i, j, n, m, b, l, d;
- bool used[N];
- vector<ll> orderlb;
- bool comp(ll a, ll b)
- {
- return books[a]>books[b];
- }
- struct library
- {
- vector<ll> v;
- ll sgup, nrb;
- }lb[N];
- void aranjeaza_librarii()
- {
- ll curr=0;
- for(int i=0;i<=l&&curr+lb[i].sgup<=d;++i)
- {
- orderlb.pb(i);
- curr+=lb[i].sgup;
- }
- }
- int main()
- {
- fast();
- freopen("input","r",stdin);
- freopen("ouput2","w",stdout);
- cin>>b>>l>>d;
- for(i=0;i<b;++i)
- cin>>books[i];
- for(i=0;i<l;++i)
- {
- cin>>n>>lb[i].sgup>>lb[i].nrb;
- for(j=0;j<n;++j)
- {
- ll x;
- cin>>x;
- lb[i].v.pb(x);
- }
- sort(lb[i].v.begin(),lb[i].v.end(),comp);
- }
- aranjeaza_librarii();
- cout<<orderlb.size()<<'\n';
- for(auto x:orderlb)
- {
- ll timp=d-lb[i].sgup;
- j=0;
- vector<ll> ordb;
- for(i=0;i<timp&&j<lb[i].v.size();++i)
- {
- for(int ind=1;ind<=lb[i].nrb&&j<lb[i].v.size();++ind,++j)
- {
- if(used[lb[i].v[j]])
- {
- --ind;
- ++j;
- continue;
- }
- ordb.pb(lb[i].v[j]);
- used[lb[i].v[j]]=1;
- }
- }
- cout<<orderlb[i]<<' '<<ordb.size()<<'\n';
- for(auto i:ordb)
- cout<<i<<' ';
- cout<<'\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement