Lose it!
You are given an array aa consisting of nn integers. Each aiai is one of the six following numbers: 4,8,15,16,23,424,8,15,16,23,42.
Your task is to remove the minimum number of elements to make this array good.
An array of length kk is called good if kk is divisible by 66 and it is possible to split it into k6k6 subsequences 4,8,15,16,23,424,8,15,16,23,42.
Examples of good arrays:
- [4,8,15,16,23,42][4,8,15,16,23,42] (the whole array is a required sequence);
- [4,8,4,15,16,8,23,15,16,42,23,42][4,8,4,15,16,8,23,15,16,42,23,42] (the first sequence is formed from first, second, fourth, fifth, seventh and tenth elements and the second one is formed from remaining elements);
- [][] (the empty array is good).
Examples of bad arrays:
- [4,8,15,16,42,23][4,8,15,16,42,23] (the order of elements should be exactly 4,8,15,16,23,424,8,15,16,23,42);
- [4,8,15,16,23,42,4][4,8,15,16,23,42,4] (the length of the array is not divisible by 66);
- [4,8,15,16,23,42,4,8,15,16,23,23][4,8,15,16,23,42,4,8,15,16,23,23] (the first sequence can be formed from first six elements but the remaining array cannot form the required sequence).
The first line of the input contains one integer nn (1≤n≤5⋅1051≤n≤5⋅105) — the number of elements in aa.
The second line of the input contains nn integers a1,a2,…,ana1,a2,…,an (each aiai is one of the following numbers: 4,8,15,16,23,424,8,15,16,23,42), where aiai is the ii-th element of aa.
Print one integer — the minimum number of elements you have to remove to obtain a good array.
5
4 8 15 16 23
5
12
4 8 4 15 16 8 23 15 16 42 23 42
0
15
4 8 4 8 15 16 8 16 23 15 16 4 42 23 42
3
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <xfunctional>
#define ll long long
#define mod 998244353
using namespace std;
int dir[][] = { {,},{,-},{-,},{,} };
const int maxn = 1e5 + ;
const long long inf = 0x7f7f7f7f7f7f7f7f; int main()
{
vector<int> p({ , , , , , }); int n;
cin >> n;
vector<int> a(n);
for (int i = ; i < n; ++i)
{
cin >> a[i];
a[i] = lower_bound(p.begin(), p.end(), a[i]) - p.begin();
} vector<int> seq();
for (int i = ; i < n; ++i)
{
if (a[i] == )
{
++seq[];
}
else
{
if (seq[a[i] - ] > )
{
--seq[a[i] - ];
++seq[a[i]];
}
}
} cout << n - seq[] * << endl;
return ;
}
Lose it!的更多相关文章
- etymon word write alb pain high alt increase large agency ag lose weight fat assist out~3
1● alb 2● write =====>rait 1● alg 2● pain 痛,疼痛 1● alt 2● high 高 1 ...
- Spoken English Practice(not always estimating your status in other's hearts. you will lose yourself when you live in other's look. do your best and walk on you own way.)
绿色:连读: 红色:略读: 蓝色:浊化: 橙色:弱读 下划线_为浊化 口语蜕变(2017/7/8) 英 ...
- POJ 2521:How much did the businessman lose
How much did the businessman lose Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9965 ...
- g/test/s/lose/won/g
包含字符串test的任意行商,用lose代替won
- Baidu set to lose leading role in digital advertising _china daily
advertising: n,广告 Online search giant Baidu Inc is set to loset its top spot in the nation's booming ...
- google chrome 32 升级变更找回user agent(google chrome lose user agent)
chrome32中user agent 找不着了?没关系,看我画的图吧.为什么是英文的,国际化嘛...
- Mac环境下mysql初始化密码问题--If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.
个人在Mac上操作数据库,遇到的启动数据库问题的简单记录 1.苹果->系统偏好设置->最下边点mysql 在弹出页面中 关闭mysql服务(点击stop mysql server) 2.进 ...
- .Net Core Package lose or not match
错误.警告的说明: 示例一: 严重性:警告 代码:MSB3106 说明 :程序集强名称“C:\Users\$(computerName)\.nuget\packages\$(packageName)\ ...
- unity, editorWindow lose data when enter play mode
我写了个editorWindow,其中有个成员变量m_x,在创建editorWindow的时候为m_x赋的值,而在editorWindow的OnGUI里把m_x显示出来. 当我开着这个editorWi ...
- SD 一轮集训 day1 lose
神TM有是结论题,我讨厌结论题mmp. 杨氏矩阵了解一下(建议去维基百科). 反正就是推柿子,使劲推,最后写起来有一点小麻烦,但是在草稿纸(然鹅我木有啊)上思路清晰的话还是没问题的. #include ...
随机推荐
- 2019牛客多校第二场H题(悬线法)
把以前的题补补,用悬线求面积第二大的子矩形.我们先求出最大子矩阵的面积,并记录其行三个方向上的悬线长度.然后排除这个矩形,记得还得特判少一行或者少一列的情况 #include <bits/std ...
- HDU6683
题意 英文 做法 考虑公比为\(\frac{a}{b}\),满足\(a>b,(a,b)=1\) 枚举长度\(k\),设序列头为\(p\),尾为\(q\),有\(p\times \frac{a^{ ...
- CF566C Logistical Questions(10-1)
题意 \(n\)个点的树,有点权,有边权,\(f(x)=\sum\limits_{i=1}^n w_idis(i,x)^{1.5}\),求最小的\(f(x)\)的\(x\) 单独考虑一条链,顺序编号, ...
- H5-设置全屏背景图片样式
.bgimg{ width: 100%; height: 95vh; margin: 0; padding: 0 .32rem; background-image: url('../image/ld. ...
- Windows10通过命令行导出笔记本电池使用信息
powercfg /batteryreport /output "D:\Thinkpad x1c\battery_report_2020_2_25.html" 可以导出电池的电池类 ...
- 02-SV数据类型
1.数据类型 内建数据类型:逻辑(logic)类型.双状态数据类型(bit,byte,shortint,int,longint).四状态数据类型(integer,time,real) 其他:定宽数组. ...
- 微信小程序之数组操作:push与concat的区别
微信小程序中需要用到数组的操作,push和concat二者功能很相像,但有两点区别. 先看如下例子: var arr = []; arr.push(); arr.push(); arr.push([, ...
- eclipse调字体大小
首先调java字体: Window -> Preferences -> General -> Appearance -> Colors and Fonts -> Java ...
- 3.Docker 操作镜像
获取镜像 之前提到过,Docker Hub 上有大量的高质量的镜像可以用,这里我们就说一下怎么获取这些镜像. 从 Docker 镜像仓库获取镜像的命令是 docker pull.其命令格式为: doc ...
- vue formatter element表格处理数据
formatter 指定一个vue methods 方法 作用:对从数据库中取出的数据进行处理后展示. <el-table-column prop="partner1" // ...