2017 Multi-University Training Contest - Team 2&&hdu 6047 Maximum Sequence
Maximum Sequence
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1450 Accepted Submission(s): 673
For the first sample:
1. Choose 2 from {bi}, then a_2…a_4 are available for a_5, and you can let a_5=a_2-2=9;
2. Choose 1 from {bi}, then a_1…a_5 are available for a_6, and you can let a_6=a_2-2=9;
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<string.h>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
typedef long long ll;
typedef unsigned long long LL;
using namespace std;
const double PI=acos(-1.0);
const double eps=0.0000000001;
const int N=+;
const ll mod=1e9+;
int a[N],b[N];
struct node{
int num;
int pos;
friend bool operator<(node aa,node bb){
return aa.num<bb.num;
}
};
priority_queue<node>q;
int main(){
int n;
while(scanf("%d",&n)!=EOF){
// memset(c,0,sizeof(c));
while(!q.empty())q.pop();
node c;
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
c.num=a[i]-i;
c.pos=i;
q.push(c);
}
//cout<<q.top().num<<endl;
for(int i=;i<=n;i++)scanf("%d",&b[i]);
sort(b+,b++n);
ll ans=;
node t;
int tt=n+;
for(int i=;i<=n;i++){
while(b[i]>q.top().pos)q.pop();
if(q.empty()==)break;
c=q.top();
ans=(ans+c.num)%mod;
t.num=c.num-tt;
t.pos=tt;
q.push(t);
tt++;
//cout<<c.num<<endl;
}
ans%=mod;
printf("%I64d\n",ans);
}
}
2017 Multi-University Training Contest - Team 2&&hdu 6047 Maximum Sequence的更多相关文章
- HDU 6047 - Maximum Sequence | 2017 Multi-University Training Contest 2
/* HDU 6047 - Maximum Sequence [ 单调队列 ] 题意: 起初给出n个元素的数列 A[N], B[N] 对于 A[]的第N+K个元素,从B[N]中找出一个元素B[i],在 ...
- 2017 Multi-University Training Contest - Team 2 &&hdu 6050 Funny Function
Funny Function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- 2017 Multi-University Training Contest - Team 2 &&hdu 6053 TrickGCD
TrickGCD Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total ...
- HDU 6047 Maximum Sequence
Maximum Sequence Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 6047 Maximum Sequence(线段树)
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=6047 题目: Maximum Sequence Time Limit: 4000/2000 MS (J ...
- HDU 6047 Maximum Sequence(贪心+线段树)
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=6047 题目: Maximum Sequence Time Limit: 4000/2000 MS (J ...
- 2017 Multi-University Training Contest - Team 2 &hdu 6055 Regular polygon
Regular polygon Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- 【2017 Multi-University Training Contest - Team 7 && hdu 6121】Build a tree
[链接]点击打开链接 [题意] 询问n个点的完全k叉树,所有子树节点个数的异或总和为多少. [题解] 考虑如下的一棵k=3叉树,假设这棵树恰好有n个节点. 因为满的k叉树,第i层的节点个数为k^(i- ...
- 【 2017 Multi-University Training Contest - Team 9 && hdu 6162】Ch’s gift
[链接]h在这里写链接 [题意] 给你一棵树,每个节点上都有一个权值. 然后给你m个询问,每个询问(x,y,a,b); 表示询问x->y这条路径上权值在[a,b]范围内的节点的权值和. [题解] ...
随机推荐
- iis设置404错误页,返回500状态码
一般在II6下,设置自定义404错误页时,只需要在错误页中选择自定义的页面,做自己的404页面即可.但是在IIS7.0及以上时,设置完404错误页后,会发现状态码返回的是500,并且可能会引起页面乱码 ...
- html5——3D案例(音乐盒子、百度钱包)
1.音乐盒子:触碰盒子,盖子会打开 2.百度钱包:触碰钱包,钱包,会180度旋转 <!DOCTYPE html> <html lang="en"> < ...
- [Windows Server 2012] 杰奇CMS安全设置
★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com ★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频. ★ 本节我们将带领大家:JIEQI ...
- Windows10下Docker的安装
安装前先说明一下,这里windows10要是专业版(Professional)或者是企业版(Enterprise),而且要是64位,否则会出现错误.不是这两个版本的win10没有自带的虚拟机(教育版未 ...
- ES6 Array返回只出现一次的元素
234
- @viewChild
https://www.cnblogs.com/mttcug/p/8004359.html
- 快速搭建vue2.0+boostrap项目
一.Vue CLI初始化Vue项目 全局安装vue cli npm install --global vue-cli 创建一个基于 webpack 模板的新项目 vue init webpack my ...
- copy and rename a file multiple times using Matlab
for file.txt***********n=10;fileinfo=importdata('file.txt');for i=1:nfilename=sprintf('file_%d.txt', ...
- springcloud(六):给Eureka Server服务器端添加用户认证
1. 还未完成 ,客户端有点问题,后期完善 2.
- hdu2008 数值统计【C++】
数值统计 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...