- 每一对客户最多只能占用一张台桌20分钟。Case 4 里,有超过20分钟的。
- 将客户们按到达的时间顺序排列,先来先服务。给客户安排台桌的策略如下:
- 对于VIP客户,如果他们来时有VIP台桌可用,那么优先安排VIP台桌,否则安排一张最快可用的。
- 对于非VIP客户,他们只能在没有VIP客户等待VIP台桌
T
的情况下,使用VIP台桌T
。在所有可使用的台桌里,安排一张最快可用的。
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
struct CUSTOMER {
int arrive;
int play;
int serve;
bool isVIP;
CUSTOMER(int _arrival, int _play, bool _isVIP) : arrive(_arrival), play(_play), isVIP(_isVIP) {
serve = 21 * 3600; }
};
bool comp1(const CUSTOMER& a, const CUSTOMER& b) {
return a.arrive < b.arrive; }
bool comp2(const CUSTOMER& a, const CUSTOMER& b) {
return a.serve < b.serve; }
int main() {
int N;
cin >> N;
vector<CUSTOMER> cus;
for (int i = 0; i < N; ++i) {
string s;
int play_time, isVIP;
cin