Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "test_runner.h"
- #include <iostream>
- #include <string>
- #include <cstdint>
- #include <map>
- #include <deque>
- using namespace std;
- typedef uint32_t ClientID;
- typedef int64_t Time;
- typedef uint16_t RoomCount;
- typedef string HotelName;
- const Time hours_24 = 86400;
- struct InputItem {
- Time time;
- HotelName hotel_name;
- ClientID client_id;
- RoomCount room_count;
- };
- class HotelBase {
- typedef map<ClientID, size_t> ClientMap;
- struct HotelItem {
- ClientMap clients;
- size_t reserved_rooms;
- };
- typedef map<HotelName, HotelItem> HotelMap;
- struct QueueItem {
- QueueItem(Time time, HotelMap::iterator hotel_it,
- ClientMap::iterator client_it, RoomCount room_count) :
- time(time), hotel_it(hotel_it), client_it(client_it), room_count(
- room_count) {
- }
- Time time;
- HotelMap::iterator hotel_it;
- ClientMap::iterator client_it;
- RoomCount room_count;
- };
- public:
- void Book(const InputItem& input);
- size_t Clients(const HotelName& hotel_name) const;
- size_t Rooms(const HotelName& hotel_name) const;
- private:
- HotelMap hotels;
- deque<QueueItem> time_queue;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement