#include #include #include #include #include #include #define ifile "input/f_libraries_of_the_world.txt" #define ofile "output/outf.txt" #define iter 1 std::size_t maxsize = 100000; static long int tdays,tdays_c,tbooks,tlibs,libcount=0; struct books { long int id; long int score; }; struct books *book= new struct books[100000]; void swap(int* a, int* b) // utility swap function { int t = *a; *a = *b; *b = t; } class library { public: int size, days,limit,less; long double finscore; int *bookid= new int[100000]; void lscore() //score function { finscore=0; if (tdays<=days) return; if (size>((tdays-days)*limit)) less=(tdays-days)*limit; else less=size; int i; for(i=0;i=lib[libord[temp]].finscore) temp = i; } if(temp!=a) swap(&libord[a],&libord[temp]); } void lcount(){ //no of libs to output long long int i=0,dc=0; //dc is daycount while(dc<=tdays_c){ dc+=lib[libord[i]].days; i++; } libcount= (i>tlibs)?tlibs:i; // prevents errors for file A } void input() //input function { int i,j; std::ifstream fin1; fin1.open(ifile); fin1 >> tbooks; fin1 >> tlibs; fin1 >> tdays; for(i = 0; i < tbooks; i++) { book[i].id = i; fin1 >> book[i].score; } for(i = 0; i < tlibs; i++) { fin1 >> lib[i].size; fin1 >> lib[i].days; fin1 >> lib[i].limit; for(j = 0; j < lib[i].size; j++) { fin1 >> lib[i].bookid[j]; } } fin1.close(); } void output() // output function { int i,j; std::ofstream fout1; fout1.open(ofile); fout1<