uva ---11136Hoax or what--优先队列即可
来源:互联网 发布:单词社交网络 微盘 编辑:程序博客网 时间:2024/04/29 20:28
//// main.cpp// uva 11136 - Hoax or what---优先队列//// Created by XD on 15/9/5.// Copyright (c) 2015年 XD. All rights reserved.//#include <iostream>#include <string>#include <queue>#include <stack>#include <stdio.h>#include <stdlib.h>#include <math.h>#include<vector>#include <string.h>#include <string>#include <algorithm>#include <set>#include <map>#include <cstdio>using namespace std ;int flag[1000000+10] ;int main(int argc, const char * argv[]) { int n , k ,d; priority_queue<int , vector<int> , greater<int > > que1 ; priority_queue<int , vector<int> , less<int > > que2 ; while (scanf("%d",&n)==1 && n!=0) { while (!que1.empty()) { que1.pop() ; } while (!que2.empty()) { que2.pop() ; } memset(flag, 0, sizeof(flag)) ; long long ans = 0 ;int large =0,low=0 ; for (int i = 0 ; i < n ; i++) { scanf("%d",&k) ; for (int j = 0; j < k ; ++j) { scanf("%d" ,&d) ; flag[d]++ ; que1.push(d) ; que2.push(d) ; } while (flag[que1.top()] == 0 ) { que1.pop() ; } flag[que1.top()]-- ; large = que1.top() ; que1.pop() ; while (flag[que2.top()] == 0 ) { que2.pop() ; } flag[que2.top()]-- ; low = que2.top() ; que2.pop() ; ans += abs(large -low) ; } printf("%lld\n",ans) ; } return 0;}
0 0
- uva ---11136Hoax or what--优先队列即可
- UVa 11136 Hoax or what (multiset or 优先队列)
- UVa-11136 Hoax or what(优先队列或multiset)
- Uva-11136-Hoax or what
- uva 11136 Hoax or what
- uva 11136 Hoax or what
- UVA - 11136 Hoax or what
- UVa:11136 Hoax or what
- UVA 11136 Hoax or what
- UVa 11136 - Hoax or what
- UVA - 11136 Hoax or what
- UVa 11136 - Hoax or what
- UVA - 11136 Hoax or what
- uva 11136 Hoax or what
- uva Hoax or what 11136(multiset)
- UVA 11136 Hoax or what (multiset)
- UVA 11136 - Hoax or what(set模拟)
- uva 11136 - Hoax or what(STL)
- Python学习01
- openssl hmac 介绍
- splay树的实现
- The Factor
- fastJson顺序遍历JSON字段
- uva ---11136Hoax or what--优先队列即可
- [LinkerScript.8] 简单的链接器脚本命令: 杂项命令 - Simple Linker Script Commands : Miscellaneous Commands
- Java中实现对象的比较
- 89 文件压缩和解压缩
- 我们有自己的论坛啦!基于Discuz构建,还不来注册~
- Android PMem 和Ashmem 介绍
- SpringMVC——接收请求参数和页面传参
- jQuery 上传头像插件Jcrop的实例
- 黑马程序员————java基础————反射