题目https://codeforces.com/problemset/problem/1214/E

就是得知奇数之间不产生影响,先造出一条链,再用偶数往里插就行。链要di从大到小排个序呀!!

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#define maxn 202000
using namespace std;
struct Node {
int ans;
int pos;
}list[maxn];
bool bml(Node a, Node b) {
return a.ans > b.ans;
}
vector<int>ans;
int main() {
int n; scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &list[i].ans);
list[i].pos = i * 2 - 1;//奇数
}
sort(list + 1, list + 1 + n, bml);
for (int i = 1; i < n; i++) {
printf("%d %d\n", list[i].pos, list[i + 1].pos);
ans.push_back(list[i].pos);
}
ans.push_back(list[n].pos); for (int i = 1; i <= n; i++) {
int t = list[i].ans + i - 2; printf("%d %d\n", ans[t], list[i].pos + 1);
if (ans.size()-1 == t) ans.push_back(list[i].pos + 1);
}
return 0;
}

  

codeforces -1214 E的更多相关文章

  1. Codeforces 1214 F G H 补题记录

    翻开以前打的 #583,水平不够场上只过了五题.最近来补一下题,来记录我sb的调试过程. 估计我这个水平现场也过不了,因为前面的题已经zz调了好久-- F:就是给你环上一些点,两两配对求距离最小值. ...

  2. codeforces 1214

    D 比赛的时候居然看漏了条件... 若在(x, y)格子,那么只能移动到(x+1, y)或(x, y+1) 这样的话就好做了,直接dp,然后统计每一种路径长度经过的点数. #include<cs ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. 利用IDEA构建springboot应用-构建好SpringBoot + SSM 框架

    一. 创建项目 选择 Spring Initiallizr 添加最基本的几个依赖 Web,MySQL,MyBatis,其他需求可以后续再添加 ; 数据库选择了 MySQL 二. 配置数据源 数据源中存 ...

  2. UVa 10220 【大整数】

    uva 10220 可采用uva 623这道题求N!,再最后稍微改一下就好. 参考代码: } #include<cstdio> #include<cstring> #inclu ...

  3. 阿里云智能数据构建与管理 Dataphin公测,助力企业数据中台建设

    阿里云智能数据构建与管理 Dataphin (下简称“Dataphin”)近日重磅上线公共云,开启智能研发版本的公共云公测!在此之前,Dataphin以独立部署方式输出并服务线下客户,已助力多家大型客 ...

  4. @NOIP2018 - D1T2@ 货币系统

    目录 @题目描述@ @题解@ @代码@ @题目描述@ 在网友的国度中共有 n 种不同面额的货币,第 i 种货币的面额为 a[i],你可以假设每一种货币都有无穷多张.为了方便,我们把货币种数为 n.面额 ...

  5. Python语言的缺点

  6. Knative Tracing 介绍

    摘要: 一个完整的业务实现想要基于 Serverless 模型来开发的话可能会分解成多个 Serverless 模块,每一个模块单独通过 Knative 的 Serving 部署,那么这些不同的 Se ...

  7. @atcoder - Japanese Student Championship 2019 Qualification - E@ Card Collector

    目录 @description@ @solution@ @accepted code@ @details@ @description@ N 个卡片放在 H*W 的方格图上,第 i 张卡片的权值为 Ai ...

  8. hdu 3272 Mission Impossible

    Mission Impossible Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  9. RequestMapping中produces属性作用

    注解RequestMapping中produces属性可以设置返回数据的类型以及编码,可以是json或者xml: @RequestMapping(value="/xxx",prod ...

  10. Pointers and Arrays_4

    1.编写程序expr,以计算从命令行输入的逆波兰表达式的值,其中每个运算符或操作数用一个单独的参数表示.例如,命令expr 2 3 4 + * 将计算表达式2×(3+4) 的值. #include & ...