Sequence《优先队列》
Description
Input
Output
Sample Input
1
2 3
1 2 3
2 2 3
Sample Output
3 3 4 这个题的意思不是很难理解,关键是思想,一点点算肯定超时了;
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
using namespace std;
int main()
{
int m,n,t,a[],b[],i,j;
priority_queue<int,vector<int>,less<int> >que;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&m,&n);
m--;
for(i=; i<n; i++)
scanf("%d",&a[i]);
sort(a,a+n);
while(m--)
{
for(i=; i<n; i++)
{
scanf("%d",&b[i]);
que.push(a[]+b[i]);//先进去N个
}
sort(b,b+n);//这个应该会用了
for(i=; i<n; i++)
{
for(j=; j<n; j++)
{
if(a[i]+b[j]>que.top())//因为有sort排序,所以,后面只会更大,可以break;
break;
que.pop();
que.push(a[i]+b[j]);
}
}
for(i=n-; i>-; i--)
{
a[i]=que.top();
que.pop();
}
}
printf("%d",a[]);
for(i=; i<n; i++)
printf(" %d",a[i]);
printf("\n");
}
return ;
}
Hint
Sequence《优先队列》的更多相关文章
- oracle SEQUENCE 创建, 修改,删除
oracle创建序列化: CREATE SEQUENCE seq_itv_collection INCREMENT BY 1 -- 每次加几个 STA ...
- Oracle数据库自动备份SQL文本:Procedure存储过程,View视图,Function函数,Trigger触发器,Sequence序列号等
功能:备份存储过程,视图,函数触发器,Sequence序列号等准备工作:--1.创建文件夹 :'E:/OracleBackUp/ProcBack';--文本存放的路径--2.执行:create or ...
- DG gap sequence修复一例
环境:Oracle 11.2.0.4 DG 故障现象: 客户在备库告警日志中发现GAP sequence提示信息: Mon Nov 21 09:53:29 2016 Media Recovery Wa ...
- Permutation Sequence
The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- [LeetCode] Sequence Reconstruction 序列重建
Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. Th ...
- [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列
Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...
- [LeetCode] Verify Preorder Sequence in Binary Search Tree 验证二叉搜索树的先序序列
Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary ...
- [LeetCode] Longest Consecutive Sequence 求最长连续序列
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...
- [LeetCode] Permutation Sequence 序列排序
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- Leetcode 60. Permutation Sequence
The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
随机推荐
- IOS-AssetsLibrary(相册)框架介绍
AssetsLibrary框架介绍: AssetsLibrary框架包含了ALAssetsLibrary,ALAssetsGroup,ALAsset,ALAssetsFilter,ALAssetRep ...
- Linux编译安装MySQL5.6
为了防止无良网站的爬虫抓取文章,特此标识,转载请注明文章出处.LaplaceDemon/SJQ. http://www.cnblogs.com/shijiaqi1066/p/4311061.html ...
- 10.29 morning
WPS转word太丑了 凑合看喽 第二题 [题目描述] 给你两个日期,问这两个日期差了多少毫秒. [输入格式] 两行,每行一个日期,日期格式保证为“YYYY-MM-DD hh:mm:ss ”这种形式. ...
- Adb connect监听指定的主机和端口/Adb监听Visual Studio Emulator for Android模拟器
语法: adb connect <host>[:<port>] 使用实例: adb connect //如果连接成功则返回 connected to 说明 在使用Visual ...
- 解决Xcode7多个模拟器的方法
xcode模拟器都这样显示,没办法判断是哪个系统,解决办法是 1.关闭xcode 2.终端输入 sudo killall -9 com.apple.CoreSimulator.CoreSimulato ...
- 10集合:List<T>,Dictionary<K,V>
List<T>泛型集合 List<T>是C#中一种快捷.易于使用的泛型集合类型,使用泛型编程为编写面向对象程序增加了极大的效率和灵活性. 1.List<T>用法 ...
- OpenCV中Mat的详解
每次碰到Mat都得反复查具体的用法,网上的基础讲解不多,难得看到一篇,赶快转来收藏~ 原文地址:http://www.opencvchina.com/thread-1039-1-1.html 目标 我 ...
- 334. Increasing Triplet Subsequence My Submissions Question--Avota
问题描述: Given an unsorted array return whether an increasing subsequence of length 3 exists or not in ...
- windows编程中 一些前缀区分 IDR和IDD
IDC_:控件的ID命名前缀(Control) IDM_:菜单的ID命名前缀(Menu) IDD_:对话框的ID命名前缀(Dialog) IDR_:资源的ID命名前缀(Resource) IDS_:字 ...
- 深入解析.NET框架
一.AOP框架 Encase 是C#编写开发的为.NET平台提供的AOP框架.Encase 独特的提供了把方面(aspects)部署到运行时代码,而其它AOP框架依赖配置文件的方式.这种 ...