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]; ...
随机推荐
- Django框架之ORM的相关操作之分页(六)
分页是每个项目必不可少要写的一个功能,该篇文章就将记录一下使用ORM写分页的过程. 假设我们的数据库里面需要显示一些数据,而这个表中的数据大约有几千条数据,那么我们不可能将所有的数据都显示出来,那么就 ...
- Catalyst 6500/6000 Switches ARP or CAM Table
译:https://www.cisco.com/c/en/us/support/docs/switches/catalyst-6500-series-switches/71079-arp-cam-ta ...
- 洛谷 P1563 玩具谜题(模拟)
嗯... 题目链接:https://www.luogu.org/problem/P1563 这道题主要问题就是弄明白顺逆时针的问题,其实可以简化成一个异或的问题:当head与x异或值为零时,即为顺时针 ...
- P1567
最大子数组和问题,dp或者分治.. #include <bits/stdc++.h> #define rep(i, a, b) for(int i = a; i <= b; i++) ...
- cascadia-code 程序员友好字体
下载地址:https://github.com/microsoft/cascadia-code/releases/download/v1911.21/Cascadia.ttf 下载后右键点击下载的文件 ...
- Ora 命令行建立账号
.使用cmd 进入 sqlplus /nolog conn system/ as sysdba .修改密码 alter user ebthis identified by new_psw; .查看用户 ...
- ThinkPHP的介绍和安装
8月6号开始学ThinkPHP了,看的是赵桐正老师的视频,.以及要去看了5集,初步感觉此框架还不错,就是要记忆哪些函数的用法感觉不太好.无论如何,既然要学了,就要遵从这个.在此,将学习时的一些笔记贴上 ...
- WordPress 网站迁移
最近想把本地的WordPress迁移到我的Linux虚拟机里面,是不是很无聊,哈哈哈,接下来就是一过程了,其实这个和迁移到线上是一样的, 1.首先将本地的文件WordPress通过FTP传到虚拟机上: ...
- scala基础API
1.对象和json转换 1.1 json取值 val json:JSONObject = JSON.parseObject(jsonMsg:String)val message:String = js ...
- Spring Boot JDBC 使用教程
总是要用到数据库的嘛,曾经我一度以为,写代码,编程就是搞数据库增删改查,甚至你设计一个系统,大部分时候在为如何设计关系型数据库努力,究其原因,是因为关系型数据库是逻辑的主要呈现. 这个系列,主要是对 ...