Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int B, L, D;
- int s[100005];
- struct Book {
- int id;
- int cost;
- Book(int id_, int cost_) : id(id_), cost(cost_) {}
- bool operator<(const Book& other) const
- {
- if (cost != other.cost)
- return cost < other.cost;
- return id < other.id;
- }
- };
- struct Library {
- int n, t, m;
- vector<Book> books;
- void sortBooks()
- {
- sort(books.begin(), books.end());
- reverse(books.begin(), books.end());
- }
- }lib[100005];
- int main(int argc, const char * argv[]) {
- scanf("%d %d %d", &B, &L, &D);
- for (int i = 0; i < B; i++) {
- scanf("%d", &s[i]);
- }
- for (int i = 0; i < L; i++)
- {
- scanf("%d %d %d", &lib[i].n, &lib[i].t, &lib[i].m);
- for (int j = 0; j < lib[i].n; j++)
- {
- int id;
- scanf("%d", &id);
- lib[i].books.push_back(Book(id, s[id]));
- }
- lib[i].sortBooks();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement