贪心,用set水过。
先按x,后按y排序,都想等时Bob放前面。然后扫一遍遇到Bob就将卡片的y值放入set中,遇到Alice就在集合中找一个能被他覆盖的y最大的数,将它擦去。因为如若能覆盖而不去覆盖了就等于浪费了这个,所以必然选择用掉这张卡片。最后统计一共成功覆盖了多少个即可。
1 #include2 #include 3 #include 4 #include 5 #define inset multiset > 6 using namespace std; 7 struct mat{ 8 int x,y,t; 9 bool operator <(const mat& m)const10 { return x