边循环边输入,用map记录,当前长度等于上一个的长度加一。记录最后一个和最大长度。先输出长度,在输出连续的序号。

代码:

#include<iostream>

#include<string>

#include<map>

using namespace std;

map<int,int> sum;

int a[2000005];

int main(){

int n,x,maxl=0,last=0;

cin>>n;

for(int i=1;i<=n;i++){

cin>>x;

a[i]=x;

sum[x]=sum[x-1]+1;//前面一个的最大长度+1

int t=sum[x];

if(t>maxl){

maxl=sum[x];//记录长度和最后一个

last=x;

}

}

cout<<maxl<<endl;

int num=last-maxl+1;//第一个

for(int i=1;i<=n;i++){

if(a[i]==num){

cout<<i<<" ";

num++;//序号+1,继续找号码

}

}

return 0;

}

Consecutive Subsequence相关推荐

  1. 【Codeforces - 977F】Consecutive Subsequence(STLmap,输出路径,dp)

    题干: You are given an integer array of length nn. You have to choose some subsequence of this array o ...

  2. cf----2019-10-20(Consecutive Subsequence,Almost Arithmetic Progression,Mentors)

    一场游戏一场空,最终 最初都由我掌控,好像一身从容,不曾有狼狈伤痛,可深夜一个人该如何相拥? You are given an integer array of length nn. You have ...

  3. Codeforces Round #479 (Div. 3)【完结】

    2022.2.28 开始复盘div3 题目链接:https://codeforces.com/contest/977 目录 A. Wrong Subtraction[签到模拟题] B. Two-gra ...

  4. 【测试点分析】1104 Sum of Number Segments (20 分)

    立志用更少的代码做更高效的表达 Given a sequence of positive numbers, a segment is defined to be a consecutive subse ...

  5. Vasya and String CodeForces - 676C(尺取法)

    High school student Vasya got a string of length n as a birthday present. This string consists of le ...

  6. Continuous Intervals Gym - 102222L(2018宁夏邀请赛暨2019银川icpc网络预选赛)

    Lamis is a smart girl. She is interested in problems about sequences and their intervals. Here she s ...

  7. biodist r语言_R语言 Biostrings包 pairwiseAlignment()函数中文帮助文档(中英文对照)

    pairwiseAlignment(Biostrings) pairwiseAlignment()所属R语言包:Biostrings Optimal Pairwise Alignment 最佳成对排列 ...

  8. 【后缀数组】【线段树】codeforces102028H Can You Solve the Harder Problem?

    H. Can You Solve the Harder Problem? time limit per test6.0 s memory limit per test1024 MB inputstan ...

  9. 百亿题典之C++编程题面试题

    原文地址:百亿题典之C++编程题面试题作者:百亿题典 1. 在linked list中找倒数第N个结点 2. 倒转linked list 3. 二叉树的结点有指向parent的指针,求最近公共祖先 4 ...

最新文章

  1. 【牛腩新闻发布系统】开发前的准备01
  2. linux进程间通信:popen函数通过管道与shell通信
  3. 世界一流大学真的建成了?26所“985”高校自评报告出炉
  4. SQLite入门与分析(二)---设计与概念
  5. 深度松下MTS视频恢复软件 v8.1.0
  6. 算法笔记_面试题_19.链表_模板及示例十几道
  7. 使用python对学生表的查询_python + mysql 实现查询表数据
  8. 【深度学习笔记】(一)Octave
  9. 文章原创度检测神器:copyscape及duplichecker
  10. 阿里云服务器可以用来干什么?
  11. VMware Workstation Ubuntu 20.04 LTS无法连接网络问题
  12. java 计算百分数问题
  13. mPEG-Phosphate,甲氧基聚乙二醇磷酸盐,mPEG-PHOS
  14. 两名一流高校硕士同年毕业论文高度雷同惹争议,怎么过的查重?
  15. 「解决方案」Acrel-2000Z变电站综合自动化系统
  16. 【计算机网络】(一)走进网络
  17. 南宁城市建设发展市政工程人才需求暴涨
  18. 12 DB操作 Hibernate Panache
  19. Modbus转Profinet网关案例 | 三菱FR-A700系列变频器配置方法
  20. 模电总结二:基本运算电路

热门文章

  1. yum.conf 配置文件详解
  2. Patch2Pix(CVPR 2021)特征点检测与匹配论文精读笔记
  3. 【动态规划法】求解TSP问题
  4. labelGo:基于 YOLOv5 的辅助标注工具
  5. HTML5/CSS3清爽后台番外篇-添加锁屏效果
  6. 数字化转型:传统零售加速向新零售转型,零售数字化驱动业绩新增长
  7. 钉钉ppt放映显示备注_[备注] 钉钉使用教程
  8. 访问windows server 2022共享文件夹提示引用 的账户当前已锁定且无法登录的解决
  9. 用一篇文章帮你破除关于facebook广告运营中的所有洗脑包
  10. 当你觉得学java学不下去的时候