P5661 公交换乘
题目传送门
思路:
根据题意,我们可以分为两种情况讨论
- 乘地铁 ,上车买票送券
- 乘公交,是否免票(队列)
考虑几个细节:
优惠券过期,直接作废(时间升序);
优惠券金额不够,下一张;
无适合的优惠券,买票。
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#define fre(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
using namespace std;
const int MAX=2147483647;
const int N=1e6;
struct node
{
int by,t,p