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;
}

最新文章

  1. win7-opengl开发环境的搭建
  2. Android Recovery Ui 分析
  3. ScrollView 的使用(非原创)
  4. DataTables warning 错误警告
  5. leetcode第29题--Substring with Concatenation of All Words
  6. haoce修改mysql
  7. POI导出多张图片到Excel
  8. AssetsUtils【读取assets、res/raw、./data/data/包名/目录下的文件】
  9. 配置Nginx部署静态资源和自动跳转到https
  10. Email发展历史
  11. [转帖]前端-chromeF12 谷歌开发者工具详解 Sources篇
  12. USART of STM32
  13. 在VS2017上使用C#调用非托管C++生成的DLL文件(图文讲解)
  14. FLIR ONE PRO热成像仪
  15. SendTo MD5 - imsoft.cnblogs
  16. 18年10月30日 NOIP模拟赛
  17. 【面试必读】一不注意就做错的五道JavaScript题目
  18. 部分函数依赖 &amp;&amp; 完全函数依赖
  19. Visual Basic 函数速查
  20. 带领技术小白入门——基于java的微信公众号开发(包括服务器配置、java web项目搭建、tomcat手动发布web项目、微信开发所需的url和token验证)

热门文章

  1. img IE下支持最大宽度
  2. [转]linux远程登入不需要密码
  3. newsyslog.conf详解
  4. 笔记 Activator.CreateInstance(Type)
  5. linux 命令——56 netstat(转)
  6. Object.prototype.toString的应用
  7. Drupal忘记管理员密码
  8. Spring Boot 2.x零基础入门到高级实战教程
  9. Linux磁盘I/O性能监控——iostat
  10. 转:maven国内镜像(maven下载慢的解决方法)