hdu4268 Alice and Bob(贪心)
来源:互联网 发布:千里眼远程监控软件 编辑:程序博客网 时间:2024/05/16 19:03
本题没完全懂,set还是没有用熟练,以后再看。
不想做贪心了,真是瞎了我的狗眼5555。。。。
#include <stdio.h>#include <cstdio>#include <set>#include <string>#include <algorithm>using namespace std;const int N = 100005;struct CARD{ int hig, wed; bool operator < (const CARD &n1) const { if(wed == n1.wed) return hig < n1.hig; return wed < n1.wed; }}A[N], B[N];int main(){ // freopen("in.txt", "r", stdin); int T, n, i, sum, p; scanf("%d", &T); while(T--) { scanf("%d", &n); multiset <int> S; S.clear(); for(i = 1; i <= n; i ++) scanf("%d%d", &A[i].hig, &A[i].wed); for(i = 1; i <= n; i ++) scanf("%d%d", &B[i].hig, &B[i].wed); sum = 0; p = 1; sort(A + 1, A + n + 1); sort(B + 1, B + n + 1); for(i = 1; i <= n; i ++) { while(p <= n && B[p].wed <= A[i].wed) S.insert(B[p ++].hig); if(S.empty()) continue; multiset <int> :: iterator it = S.lower_bound(A[i].hig); if(*(it) == A[i].hig) { sum ++; S.erase(it); } else { if(it == S.begin()) continue; else { sum ++; S.erase(-- it); } } } printf("%d\n",sum); } return 0;}
0 0
- hdu4268 Alice and Bob(贪心)
- HDU4268 Alice and Bob 【贪心】
- hdu4268 排序贪心Alice and Bob
- HDU4268 Alice and Bob【贪心+SET】
- hdu4268 Alice and Bob
- HDU4268 Alice and Bob
- hdu4268 Alice and Bob
- hdu4268 Alice and Bob
- hdu4268 Alice and Bob,multiset
- hdu4268 Alice and Bob 长春网络赛
- [STL][multiset] hdu4268 Alice and Bob
- hdu4268 Alice and Bob(二维贪心的固定思想 STL的multiset的二分查找函数实现)
- HDU 4268 Alice and Bob(贪心)
- HDU 4268 Alice and Bob(贪心)
- HDU 4268 Alice and Bob (贪心)
- HDU 4268 Alice and Bob(贪心)
- hdu 4268 Alice and Bob(贪心)
- HDU4268 2012ACM长春赛区网络赛 Alice and Bob
- Light OJ 1140 How Many Zeroes? (数位DP)
- 反向输入字符串--经典递归
- hdu1503Advanced Fruits【最长公共子序列】
- 第一天,First Blood
- 处理把BOOL值存入NSMutableDictionary,从NSMutableDictionary中取出BOOL值
- hdu4268 Alice and Bob(贪心)
- Codeforces 622
- [爬虫系列(一)]爬取豆瓣电影排行前250
- bzoj2588 Count on a tree dfs&主席树
- windows绘图-区域CRgn
- 开发环境
- Test
- 第1章 python 打印输出实战
- socket编程 -- 网络字节序、IP地址转换、sockaddr数据结构