Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)B(SET)
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[2007];
set<int>s;
int main(){
int n;
cin>>n;
int iend=n+1;
for(int i=1;i<=n;++i)
cin>>a[i];
while(iend>1&&!s.count(a[iend-1]))
s.insert(a[--iend]);
int ans=9999;
for(int i=1;iend<=n+1;++iend){
while(i<iend&&!s.count(a[i]))
s.insert(a[i++]);
ans=min(ans,iend-i);
s.erase(a[iend]);
}
cout<<ans;
return 0;
}
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)B(SET)的更多相关文章
- Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-D. Restore Permutation-构造+树状数组
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-D. Restore Permutation-构造+树状数组 [Pro ...
- Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-C. Magic Grid-构造
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-C. Magic Grid-构造 [Problem Descripti ...
- Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-E. Let Them Slide-思维+数据结构
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-E. Let Them Slide-思维+数据结构 [Problem ...
- Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) F. Bits And Pieces sosdp
F. Bits And Pieces 题面 You are given an array
- Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) G. Polygons 数论
G. Polygons Description You are given two integers
- Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) (1208F,1208G,1208H)
1208 F 大意: 给定序列$a$, 求$\text{$a_i$|$a_j$&$a_k$}(i<j<k)$的最大值 枚举$i$, 从高位到低位贪心, 那么问题就转化为给定$x$ ...
- RMQ+差分处理(Let Them Slide)Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)
题意:https://codeforc.es/contest/1208/problem/E 现有n行w列的墙,每行有一排连续方块,一排方块可以左右连续滑动,且每个方块都有一个价值,第i 列的价值定义为 ...
- 线段树维护最后一个0的位置(Restore Permutation)Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)
题意:https://codeforc.es/contest/1208/problem/D 给你长度为n的序列,s[i]的值为p[1]到p[i-1]中比p[i]小的数的和,让你求出p序列. 思路: 首 ...
- Codeforces Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)
传送门 A. XORinacci 手玩三四项发现序列就是 $a,b,a\ xor\ b,a,b,...$,直接输出即可 #include<iostream> #include<cst ...
- Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)E(多重集维护)
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;long long ans[1000007]; ...
随机推荐
- pwnable.kr-random-Writeup
MarkdownPad Document *:first-child { margin-top: 0 !important; } body>*:last-child { margin-botto ...
- tomcat使用中的笔记
1.修改tomcat命令窗口的名字 平时在使用tomcat的时候,经常会在一台机器上启动多个tomcat,但是默认的情况下启动多个就不好区分对应启动了什么应用,这时我们就可以通过修改tomcat窗口名 ...
- python web django 2nd level -- 待更新
练习代码位置 实例代码位置 --> app: myblog Form 利用Form表单验证,自己写的html 思路: 新建一个类 LoginForm(forms.Form) 新建对象 obj = ...
- jsTree的checkbox默认选中和隐藏
jstree复选框自定义显示隐藏和初始化默认选中 首先需要配置 Checkbox plugin "plugins" : ['checkbox'] 设置默认选中状态(checkbox ...
- Dataguard单机—>单机
本演示案例所用环境: primary Standby OS Hostname CHINA-DB1 CHINA-DB2 OS Version SUSE Linux Enterprise Server 1 ...
- CentOS7.6配置ip
查看CentOS版本信息 [root@localhost ~]# cat /etc/redhat-release CentOS Linux release (Core) 配置ip [root@loca ...
- nginx解决WordPress 上传到服务器后页面404错误的方法
人啊,要说你傻了吧,真是啥事都能碰到: 因为换了nginx,把新做的上传到服务器配置好后,就主页和后台能打开,其他的所有页面,全是404,果真404和502是我最讨厌的数字啊,这让我很怀疑人生啊,怀疑 ...
- [代码记录] C语言链表
#开始 · 简单的创建链表 #代码 #include<conio.h> #include<stdio.h> #include<stdlib.h> struct St ...
- Linux 的三种软件安装包介绍
通过RPM软件包来安装 说起RPM(RedHat Package Management)标准的软件包,大家可能都会想起大名鼎鼎的REDHAT公司,正是RPM软件包发行方式的出现,使Linux中的应用软 ...
- CSP-201609-3 炉石传说
问题描述 <炉石传说:魔兽英雄传>(Hearthstone: Heroes of Warcraft,简称炉石传说)是暴雪娱乐开发的一款集换式卡牌游戏(如下图所示).游戏在一个战斗棋盘上进行 ...