本题是模拟题。

我们可以用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. JS获取标签内容的方法

    JS获取标签内容的方法 测试代码 <!DOCTYPE html> <html lang="en"> <head> <meta charse ...

  2. Tomcat配置绝对路径

    JSP访问项目工程下的地址 <video width="640" height="264" controls src="http://local ...

  3. 第31届IMO 第2题

    题目 设n>=3,考虑一个圆上由2n-1个不同点构成的集合E.现给E中恰好k个点染上黑色,如果至少有一对黑点使得这两个黑点之间的弧上(两段弧中的某一个)包含恰好E中的n个点,就成这样的染色方法是 ...

  4. 悲催的二柱子们做小学二年级四则运算题(Javaweb)

    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding= ...

  5. Leetcode Week5 Maximum Sum Circular Subarray

    Question Given a circular array C of integers represented by A, find the maximum possible sum of a n ...

  6. cartographer保存地图

    手持激光,并用cartographer建图,保存的地图是.pbstream格式 ht@ht:~$ rosservice call /write_state /home/ht/Desktop/carto ...

  7. linux100讲——03 什么是linux

    1.linux 有两种含义: 一种是linus 编写的开源操作系统的内核 另一种是广义的操作系统 2.linux的第一印象 服务端操作系统和客户端操作系统要做的事情不一样 命令行操作方式与图形界面的差 ...

  8. css实现聊天气泡效果

      --------------------------------------- css功能强大,能实现很多炫 酷的效果,今天给大家分享 用css3绘制聊天气泡的方法: -------------- ...

  9. LED Mood Light Factory-Smart Mood Light: Control System Principle

    Intelligent devices have become more and more widespread in our lives. Intelligent scene lights are ...

  10. PP: Robust Anomaly Detection for Multivariate Time Series through Stochastic Recurrent Neural Network

    PROBLEM: OmniAnomaly multivariate time series anomaly detection + unsupervised 主体思想: input: multivar ...