• 题意:给你一串只含\(4,8,15,16,23,42\)的序列,如果它满足长度是\(6\)的倍数并且有\(\frac {k}{6}\)个子序列是\([4,8,15,16,23,42]\),则定义它是好的,问最少删除多少元素使得序列是好的.

  • 题解:我们开个桶(要离散化)记录这些数字出现的次数,然后线性遍历,当遇到\(4\),我们就直接让它++,否则判断它的前一个数的次数是否大于\(0\),如果是,那么它的前一个数的次数--,它自己次数++,如果前一个数出现的次数为\(0\),那么当前这个数就不能构成我们想要的序列,直接报废,最后我们可以得到满足条件的序列个数\(cnt[6]\),序列中含有\(6\)个数,所以最后要删去的元素个数就为\(n-6*cnt[6]\).

  • 代码:

    int n;
    int p[N];
    int a[N];
    int cnt[N]; int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    p[4]=1,p[8]=2,p[15]=3,p[16]=4,p[23]=5,p[42]=6;
    for(int i=1;i<=n;++i) cin>>a[i];
    for(int i=1;i<=n;++i){
    if(a[i]==4) cnt[1]++;
    if(cnt[p[a[i]]-1]){
    cnt[p[a[i]]-1]--;
    cnt[p[a[i]]]++;
    }
    } cout<<n-6*cnt[6]<<endl; return 0;
    }

Codeforces Round #565 (Div. 3) C. Lose it! (思维)的更多相关文章

  1. Codeforces Round #565 (Div. 3) C. Lose it!

    链接: https://codeforces.com/contest/1176/problem/C 题意: You are given an array a consisting of n integ ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. Codeforces Round #565 (Div. 3) B

    B. Merge it! 题目链接:http://codeforces.com/contest/1176/problem/B 题目 You are given an array a consistin ...

  6. Codeforces Round #565 (Div. 3) A

    A. Divide it! 题目链接:http://codeforces.com/contest/1176/problem/A 题目 You are given an integer n You ca ...

  7. Codeforces Round #565 (Div. 3) F.Destroy it!

    题目地址:http://codeforces.com/contest/1176/problem/F 思路:其实就是一个01背包问题,只是添加了回合和每回合的01限制,和每当已用牌数到了10的倍数,那张 ...

  8. 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/ ...

  9. Codeforces Round #353 (Div. 2) C. Money Transfers (思维题)

    题目链接:http://codeforces.com/contest/675/problem/C 给你n个bank,1~n形成一个环,每个bank有一个值,但是保证所有值的和为0.有一个操作是每个相邻 ...

随机推荐

  1. Jenkins上实现Python + Jenkins + Allure Report 接口自动化测试持续集成,最终测试报告用allure-report进行展示

    项目介绍 接口功能测试应用:http://www.weather.com.cn/data/cityinfo/<city_code>.html 测试功能:获取对应城市的天气预报 源码:Pyt ...

  2. LeetCode559.N 叉树的最大深度

    题目 法一.层序遍历 1 class Solution { 2 public: 3 int maxDepth(Node* root) { 4 if(root== NULL) return 0; 5 q ...

  3. ftp交互和控制命令总结

    一.FTP管理: 基于tcp,首先有客户端相服务端的知名端口21发起tcp连接建立ftp控制连接,控制连接在整个会话期间都保持打开,只用来发送连接/传送请求. 这里分为两种模式: 主动模式(PORT) ...

  4. VPS下环境漏洞部署

    No.1 声明 1.由于本环节运行在公网,如何同样复现情况,复现成功后请立即关闭环境! 2.本环境仅用于漏洞复现! No.2 安装docker curl -s https://get.docker.c ...

  5. VKM5对应的BAPI或者函数

    在业务上,当一个交货单创建后,可能需要使用事物VKM5进行批准(解冻)才能做后续的捡配,发货过账等操作,通过搜索引擎发现,很多人也都会问是否有对应的bapi或者函数,替代VKM5,能够自开发程序进行批 ...

  6. uni-app开发经验分享六:页面跳转及提示框

    在我们开发的uni-app的过程中,页面跳转及提示框往往是我们做数据交互及结果反馈所要使用的功能,这里分享下我收集的一些方法及看法. 一:页面跳转 事件跳转 :指通过tap等事件来实现页面的跳转,跳转 ...

  7. Linux网卡没有eth0显示ens33原因以及解决办法

    原因 首先说明下eth0与ens33的关系: 目前的主流网卡为使用以太网络协定所开发出来的以太网卡 (Ethernet),因此我们 Linux 就称呼这种网络接口为 ethN (N 为数字). 举例来 ...

  8. 你可能会问,为什么不直接进入 CLOSED 状态,而要停留在 TIME_WAIT 这个状态?

    你可能会问,为什么不直接进入 CLOSED 状态,而要停留在 TIME_WAIT 这个状态? 划重点,2MSL 的时间是从主机 1 接收到 FIN 后发送 ACK 开始计时的:如果在 TIME_WAI ...

  9. Understanding go.sum and go.mod file in Go

    https://golangbyexample.com/go-mod-sum-module/ Understanding go.sum and go.mod file in Go (Golang) – ...

  10. WireGuard 教程:使用 DNS-SD 进行 NAT-to-NAT 穿透

    原文链接:https://fuckcloudnative.io/posts/wireguard-endpoint-discovery-nat-traversal/ WireGuard 是由 Jason ...