Codeforces Round #565 (Div. 3) C. Lose it!
链接:
https://codeforces.com/contest/1176/problem/C
题意:
You are given an array a consisting of n integers. Each ai is one of the six following numbers: 4,8,15,16,23,42.
Your task is to remove the minimum number of elements to make this array good.
An array of length k is called good if k is divisible by 6 and it is possible to split it into k6 subsequences 4,8,15,16,23,42.
Examples of good arrays:
[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] (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] (the order of elements should be exactly 4,8,15,16,23,42);
[4,8,15,16,23,42,4] (the length of the array is not divisible by 6);
[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).
思路:
刚开始题目看错。。以为任意顺序的子序列。
map将值映射到1-6,然后每次遇到2-5中的x,从x-1的个数中移一个到x,最后看能移几个到6.
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7;
int n, m, k, t;
map<int, int> mp;
int main()
{
cin >> n;
mp[4] = 1;
mp[8] = 2;
mp[15] = 3;
mp[16] = 4;
mp[23] = 5;
mp[42] = 6;
int vis[10] = {0};
int res = 0, temp = 0;
int last = 1;
int flag = 0;
for (int i = 1;i <= n;i++)
{
int v;
cin >> v;
if (mp[v] == 1)
vis[mp[v]]++;
else if (vis[mp[v]-1]>0)
{
vis[mp[v]-1]--;
vis[mp[v]]++;
}
}
cout << n-6*vis[6] << endl;
return 0;
}
Codeforces Round #565 (Div. 3) C. Lose it!的更多相关文章
- Codeforces Round #565 (Div. 3) C. Lose it! (思维)
题意:给你一串只含\(4,8,15,16,23,42\)的序列,如果它满足长度是\(6\)的倍数并且有\(\frac {k}{6}\)个子序列是\([4,8,15,16,23,42]\),则定义它是好 ...
- Codeforces Round #565 (Div. 3) B. Merge it!
链接: https://codeforces.com/contest/1176/problem/B 题意: You are given an array a consisting of n integ ...
- Codeforces Round #565 (Div. 3) A. Divide it!
链接: https://codeforces.com/contest/1176/problem/A 题意: You are given an integer n. You can perform an ...
- Codeforces Round #565 (Div. 3) B
B. Merge it! 题目链接:http://codeforces.com/contest/1176/problem/B 题目 You are given an array a consistin ...
- Codeforces Round #565 (Div. 3) A
A. Divide it! 题目链接:http://codeforces.com/contest/1176/problem/A 题目 You are given an integer n You ca ...
- Codeforces Round #565 (Div. 3) F.Destroy it!
题目地址:http://codeforces.com/contest/1176/problem/F 思路:其实就是一个01背包问题,只是添加了回合和每回合的01限制,和每当已用牌数到了10的倍数,那张 ...
- Codeforces Round #565 (Div. 3)
传送门 A. Divide it! •题意 给定一个数n, 每次可以进行下列一种操作 1.如果n可以被2整除,用n/2代替n 2.如果n可以被3整除,用2n/3代替n 3.如果n可以被5整除,用4n/ ...
- Codeforces Round #565 (Div. 3)--D. Recover it!--思维+欧拉筛
D. Recover it! Authors guessed an array aa consisting of nn integers; each integer is not less than ...
- Codeforces Round #467 (div.2)
Codeforces Round #467 (div.2) 我才不会打这种比赛呢 (其实本来打算打的) 谁叫它推迟到了\(00:05\) 我爱睡觉 题解 A. Olympiad 翻译 给你若干人的成绩 ...
随机推荐
- 蓝色科技AE宣传片头光晕视频
蓝色科技AE宣传片头光晕视频素材,蓝色AE炫光素材,科技AE片头,精美,AE特效,绚丽,AE模板,视频素材,动画. 地址:http://www.huiyi8.com/xuanguang/ae/
- URL过滤
URL过滤 就是网址过滤.把不安全的.少儿不宜的.政治的东西过滤掉,访问这些网址就会提示受限,不能访问. 一.url过滤简介 针对企业对员工上网行为的控制管理,可以采用URL过滤技术.如企业不允许研发 ...
- 暑假集训Chapter1 贪心
为什么要今天写呢? 明天全力研究Johnson和一些奇奇怪怪的贪心 今天把能写的都写了 T1T2太水了直接上代码吧 #include<bits/stdc++.h> #define LL l ...
- tyvj1061移动服务——DP
题目:http://www.joyoi.cn/problem/tyvj-1061 DP记录状态为当前任务时不在此任务位置上的两个人的位置(因为一定有一个人在此任务位置上): 不妨设初始位置p[0]=3 ...
- Day05:装饰器,三元表达式,函数的递归,匿名/内置函数,迭代器,模块,开发目录
上节课复习:1.函数的对象 函数可以被当作数据取处理2.函数嵌套 嵌套调用:在调用一个函数时,函数体代码又调用了其他函数 嵌套定义:在一个函数内部又定义了另一个函数 def foo( ...
- 利用NDK崩溃日志查找BUG
转自:http://www.tuicool.com/articles/qQNfUfe 背景介绍 本文主要内容: 利用android的crash log来对c++开发的android应用进行错误定位. ...
- caffe Dtype
http://blog.luoyetx.com/2015/10/reading-caffe-2/
- JavaScript高级程序设计学习笔记第十章--DOM
1.DOM:文档对象模型,是针对 HTML 和 XML 文档的一个 API(应用程序编程接口). 2.DOM 可以将任何 HTML 或 XML 文档描绘成一个由多层节点构成的结构. 3.文档节点是每个 ...
- Sharding & IDs at Instagram, Flickr ID generation
Instagram: http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram Flickr ...
- K-S Test
K-S test, test for the equality of continuous, one-dimensional probability distribution that can be ...