ref

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n, d[305], deg[1005];
vector<pair<int,int> > vec;
int main(){
cin>>n;
for(int i=1; i<=n; i++)
scanf("%d", &d[i]);
int l=1, r=n, q=d[n]+1, lst=0;
for(int i=1; i<=q; i++){
if(l<=r && q-i+deg[i]==d[r]){
lst = 1;
r--;
}
else if(l<=r && deg[i]==d[l]){
lst = 0;
l++;
}
if(lst){
for(int j=i+1; j<=q; j++){
deg[i]++; deg[j]++;
vec.push_back(make_pair(i,j));
}
}
}
cout<<vec.size()<<endl;
for(int i=0; i<vec.size(); i++)
printf("%d %d\n", vec[i].first, vec[i].second);
return 0;
}

cf976d Degree Set的更多相关文章

  1. Max Degree of Parallelism最大并行度配置

    由于公司的业务在急速增长中,发现数据库服务器已经基本撑不住这么多并发.一方面,要求开发人员调整并发架构,利用缓存减少查询.一方面从数据库方面改善并发.数据库的并行度可设置如下: 1)cost thre ...

  2. SQL Server数据库与max degree of parallelism参数

    我们今天主要向大家讲述的是SQL Server数据库中的max degree of parallelism参数,当 SQL Server 数据库在具N个微处理器或是 CPU 的计算机上运行时,它将为每 ...

  3. Oracle数据库作业-6 29、查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree从高到低次序排序。 select tname,prof from teacher where depart = '计算机系' and prof not in ( select prof from teacher where depart 。

    29.查询选修编号为"3-105"课程且成绩至少高于选修编号为"3-245"的同学的Cno.Sno和Degree,并按Degree从高到低次序排序. selec ...

  4. 关于索引degree设置的问题

    --并行查询 可以使用并行查询的情况 1. Full table scans, full partition scans, and fast full index scans 2. Index ful ...

  5. diameter - degree problem

    如今要构建一个网络模型,网络中的每一个节点最多和 d 个节点相连接, 且信息的传播从随意一个节点到另外随意一个节点的"最短路径" (路径依照单位路径算)都不能超过 k,问网络中最多 ...

  6. HDU 2454 Degree Sequence of Graph G(Havel定理 推断一个简单图的存在)

    主题链接:pid=2454">http://acm.hdu.edu.cn/showproblem.php?pid=2454 Problem Description Wang Haiya ...

  7. Misha and Palindrome Degree

    Misha and Palindrome Degree 题目链接:http://codeforces.com/problemset/problem/501/E 贪心 如果区间[L,R]满足条件,那么区 ...

  8. leetcode 697. Degree of an Array

    题目: Given a non-empty array of non-negative integers nums, the degree of this array is defined as th ...

  9. LeetCode 697. Degree of an Array (数组的度)

    Given a non-empty array of non-negative integers nums, the degree of this array is defined as the ma ...

随机推荐

  1. vuejs 生命周期 updated

    前段时间 公司领导提示出了一个需求就是 像微信朋友圈一样,刷列表 一直刷到 底部或者是半中央,然后点击返回或者是离开一下 页面,再辞进入朋友圈页面依然现实的还是之前滚动的位置. 我现在做的公司贷后系统 ...

  2. 【转】This Android SDK requires Android Developer Toolkit version 20.0.0 or above

    本人最近在操作更新ANDROID SDK时出现类似于题目中的错误,是一启动ECLIPSE时.但是,我现在只是想恢复到原先的开发环境.于是找到本文,方法有效!!! windows 下面安装Android ...

  3. Android-->RxJava2更新体验

    截止日前最新版2017-3-15: RxJava compile ‘io.reactivex:rxjava:’ compile ‘io.reactivex:rxandroid:’ RxJava2 co ...

  4. Eucalyptus-instance启动后查看运行状态

    1.前言 在eucalyptus中通过虚拟机模板,创建并启动一个虚拟机,这个时候虚拟机启动正常,但是外部一直无法访问也ping不通,正对这种情况我们如何检查排除问题呢? 两种检查问题的方法: 1).在 ...

  5. Eucalyptus-利用镜像启动一个Windows Server 2008r2实例

    1.前言 使用kvm制作Eucalyptus镜像(Windows Server 2008r2为例)——http://www.cnblogs.com/gis-luq/p/3990792.html 上一篇 ...

  6. CentOS下内核TCP参数优化配置详解

    主动关闭的一方在发送最后一个ACK后就会进入TIME_WAIT状态,并停留2MSL(Max Segment LifeTime)时间,这个是TCP/IP必不可少的. TCP/IP的设计者如此设计,主要原 ...

  7. amap -bq 192.168.5.9 80 3306

    amap -bq 192.168.5.9 80 3306 查看运行在指定端口上运行的服务

  8. 禁止ASP.NET MVC模型绑定时将空字符串绑定为null

    为model添加[DisplayFormat(ConvertEmptyStringToNull = false)] [Display(ResourceType = typeof(AppStrings) ...

  9. GBase数据库存储过程——批量删除多个数据表的数据

    偶尔需要清空一下数据库,重装成本太高. --清空历史存储过程 DROP Procedure `dap_model`.`delete_datas` ; --创建存储过程 DELIMITER // CRE ...

  10. raw_input功能

    摘要: raw_input()  &  input() raw_input的功能是方便的从控制台读入数据.  input与raw_input都是Python的内建函数,实现与用户的交互,但是功 ...