本题是模拟题。

我们可以用b数组记录每个数字在a数组中出现的最后位置,然后从0到2·10^5依次寻找最后一次出现最早的数(注意是0!),最后统计输出即可。

AC代码:

 #include <bits/stdc++.h>//万能头文件

 using namespace std;//使用标准名字空间

 inline int read()//快速读入
{
int f=,x=;
char c=getchar(); while(c<'' || c>'')
{
if(c=='-')f=-;
c=getchar();
} while(c>='' && c<='')
{
x=x*+c-'';
c=getchar();
} return f*x;
} int n,a[]/*输入数组*/,b[]/*存储最后一次出现的位置*/,m=/*出现最早的位置*/,ans/*答案*/; int main()
{
n=read();//输入 for(register int i=; i<=n; i++)
{
a[i]=read(); b[a[i]]=i;//记录a[i]出现的最晚位置
} for(register int i=; i<=; i++) //枚举最后一次出现最早的数,注意是从0开始!
{
if(b[i]> && b[i]<m)//如果这个数出现过且位置比当前最小值还小
{
m=b[i];//记录最小位置 ans=i;//记录答案
}
} printf("%d",ans);//输出答案 return ;//结束
}
												

题解【Codeforces886B】Vlad and Cafes的更多相关文章

  1. Codeforces 890B - Vlad and Cafes Set

    B. Vlad and Cafestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputou ...

  2. Codeforces Round #445 B. Vlad and Cafes【时间轴】

    B. Vlad and Cafes time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  3. 【Codeforces Round #445 (Div. 2) B】Vlad and Cafes

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 傻逼模拟 [代码] #include <bits/stdc++.h> using namespace std; cons ...

  4. Codeforces Round #445

    ACM ICPC 每个队伍必须是3个人 #include<stdio.h> #include<string.h> #include<stdlib.h> #inclu ...

  5. CF 1131A,1131B,1131C,1131D,1131F(Round541 A,B,C,D,F)题解

    A. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  6. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  7. noip2016十连测题解

    以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...

  8. BZOJ-2561-最小生成树 题解(最小割)

    2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lyd ...

  9. Codeforces Round #353 (Div. 2) ABCDE 题解 python

    Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring P ...

随机推荐

  1. SurfaceView 与view区别详解

    SurfaceView 与view区别详解 https://blog.csdn.net/u011339364/article/details/83347109 2018年10月24日 17:20:08 ...

  2. spark.streaming.kafka.maxRatePerPartition的理解

    spark.streaming.kafka.maxRatePerPartition设定对目标topic每个partition每秒钟拉取的数据条数. 假设此项设为1,批次间隔为10s,目标topic只有 ...

  3. Time series data mining

    from here 论文Timeseries data mining(2012)中提出:时间序列数据挖掘包括7个基本任务和3个基础问题: 7 tasks: query by content clust ...

  4. dva-loading 实践用法

    dva 中页面过渡效果封装的很好,下面介绍常用的两个 js 库. 之前对 dva-loading 理解存在误区,认为只要在 index.js 中配置一下就没事了,事实上 dva-loading 只是提 ...

  5. 1级搭建类108-Oracle 11gR2 SI FS(Windows Server 2019)公开

    Oracle 11gR2 单实例文件系统在Windows Server 2019上的安装 在线查看

  6. 2018ICPC南京站Problem G. Pyramid

    题意: 找有多少个等边三角形 解析: 首先打标找规律,然后对式子求差分 0,1,5,15,35,70,126,210... 1,4,10,20,35,56... 3,6,10,15,21... 3,4 ...

  7. pytest学习8-运行上次执行失败的用例

    该插件提供了两个命令行选项,用于重新运行上次pytest调用的失败: --lf,--last-failed- 只重新运行上次失败的用例,如果没有失败则全部运行 --ff,--failed-first- ...

  8. Pytest学习7-参数化

    在测试过程中,参数化是必不可少的功能,本文就讨论下pytest的几种参数化方法 @pytest.mark.parametrize:参数化测试函数 1.内置的pytest.mark.parametriz ...

  9. asm相关内容想下载(包括 jar 包)

    网址:http://download.forge.ow2.org/asm/

  10. Python并发学习

    #Python并发 多任务 多进程 多线程 线程同步 #多任务处理 多任务处理:使得计算机可以同时处理多个任务 听歌的同时QQ聊天.办公.下载文件 实现方式:多进程.多线程 #程序和进程 程序:是一个 ...