cf976d Degree Set
#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的更多相关文章
- Max Degree of Parallelism最大并行度配置
由于公司的业务在急速增长中,发现数据库服务器已经基本撑不住这么多并发.一方面,要求开发人员调整并发架构,利用缓存减少查询.一方面从数据库方面改善并发.数据库的并行度可设置如下: 1)cost thre ...
- SQL Server数据库与max degree of parallelism参数
我们今天主要向大家讲述的是SQL Server数据库中的max degree of parallelism参数,当 SQL Server 数据库在具N个微处理器或是 CPU 的计算机上运行时,它将为每 ...
- 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 ...
- 关于索引degree设置的问题
--并行查询 可以使用并行查询的情况 1. Full table scans, full partition scans, and fast full index scans 2. Index ful ...
- diameter - degree problem
如今要构建一个网络模型,网络中的每一个节点最多和 d 个节点相连接, 且信息的传播从随意一个节点到另外随意一个节点的"最短路径" (路径依照单位路径算)都不能超过 k,问网络中最多 ...
- HDU 2454 Degree Sequence of Graph G(Havel定理 推断一个简单图的存在)
主题链接:pid=2454">http://acm.hdu.edu.cn/showproblem.php?pid=2454 Problem Description Wang Haiya ...
- Misha and Palindrome Degree
Misha and Palindrome Degree 题目链接:http://codeforces.com/problemset/problem/501/E 贪心 如果区间[L,R]满足条件,那么区 ...
- 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 ...
- 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 ...
随机推荐
- python3对多线程处理
参考博客: https://blog.csdn.net/u010339879/article/details/86506450 https://blog.csdn.net/qq_33961117/ar ...
- Spring mvc + maven + tomcat配置问题
在用maven搭建spring mvc时候, 个人遇到过很多的问题, 现在把遇到的问题总结下: 1. 首先点击项目->Run As->Maven clean, 这一步把之前不管有没有ma ...
- 美国L1签证面谈的时候一般VO会问到什么问题?
L签证:L签证签发给被其中国公司调派到美国分公司或合资公司工作的人员.申请人必须将在美国担任经理级职务或具有专业知识,且在申请签证前的三年中至少为同一雇主或公司连续工作至少一年.签证签发费将因签证的入 ...
- DELL R730安装ESXI虚拟化
dell安装esxi需要dell官方提供的镜像文件地址:http://www.dell.com/support/article/us/en/04/SLN290857/dell%E5%AE%9A%E5% ...
- hadoop2.4 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
在Ubuntu上安装完hadoop2.4以后,使用以下命令: hadoop fs -ls // :: WARN util.NativeCodeLoader: Unable to load native ...
- app再次进入数据不加载问题
问题原因:触发点击事件在加载页面之前完成. 1.调整了一下页面加载顺序 2.增加了settime的时间
- tomcat下的公共jar包配置
1.创建my-lib文件夹 . 在conf文件中的catalina.properties中配置如下 # Licensed to the Apache Software Foundation (ASF) ...
- IOS UITextFieldDelegate (常用的代理方法)
#pragma mark - UITextFieldDelegate // 返回NO代表着文本输入框不可以改变(不可以编辑) - (BOOL)textField:(UITextField *)text ...
- a low memory warning should only destroy the layer’s bitmap
https://stablekernel.com/view-controller-in-ios-6/ Some of you may have noticed that your view contr ...
- 【BZOJ1060】[ZJOI2007] 时态同步(树形DP)
点此看题面 大致题意: 给你一棵带权树,每次使用道具可以将某条边的边权加\(1\),问你至少需要使用多少次道具,才能使每个叶子节点到根节点的距离相等. 贪心的思想 首先,我们应该先有一个贪心的思想. ...