hdu 2275数据结构水题
2012-11-02 20:26
260 查看
用multiset就可以水过,不过我这种方法用int会WA,应该是测试数据中有int的最小值,如果用int保存再取负的话就会溢出,以后要注意~~
/* * hdu2275/win.cpp * Created on: 2012-11-2 * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <iostream> #include <algorithm> #include <queue> #include <set> #include <map> #include <stack> #include <string> #include <vector> #include <deque> #include <list> #include <functional> #include <numeric> #include <cctype> using namespace std; typedef long long LL; int main() { #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif int N, a; LL temp; char str[100]; while(scanf("%d", &N) == 1) { multiset<LL> S; while(N--) { scanf("%s %d", str, &a); temp = a; if(strcmp(str, "Push") == 0) { S.insert(-temp); }else { multiset<LL>::iterator it = S.lower_bound(-temp); if(it != S.end()) { temp = -(*it); printf("%d\n", (int)temp); S.erase(it); }else { puts("No Element!"); } } } putchar('\n'); } return 0; }
相关文章推荐
- hdu 1908数据结构水题
- hdu 2019:数列有序!(数据结构,直接插入排序+折半插入排序)
- (hdu step 8.1.6)士兵队列训练问题(数据结构,简单模拟——第一次每2个去掉1个,第二次每3个去掉1个.知道队伍中的人数<=3,输出剩下的人 )
- HDU1012 POJ1517 ZOJ1113 UVALive2083 u Calculate e【水题】
- HDU 2489 Minimal Ratio Tree(数据结构-最小生成树)
- HDU 5099 Comparison of Android versions(模拟-水题)
- HDU 5137 数据结构之最短路
- HDU 4278 Faulty Odometer【水题】
- HDU - 2091 空心三角形 水题,但是有点坑...
- HDU 1173 采矿(某类水题)
- HDU 5645 DZY Loves Balls 水题
- HDU 5090 Game with Pearls(上海邀请赛水题)
- HDU 1037 Keep on Truckin'(水题)
- HDU 6168 - Numbers 水题 2017 Multi-University Training Contest - Team 9
- hdu 5585 水题 Numbers 2015.11.28 bestcoder 1001
- HDU - 1232 畅通工程(并查集水题)
- HDU 1412 {A} + {B} STL<set> 水题
- hdu 4576 Robot (概率水题)
- HDU 5994 Fxx and string(【暴力枚举】水题)
- HDOJ 2107 Founding of HDU(水题)