Educational Codeforces Round 76 (Rated for Div. 2)E(最长上升子序列)
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[200007],b[200007],c[200007];
int cnt1[200007],cnt2[200007],cnt3[200007];
int mn[200007];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int k1,k2,k3;
cin>>k1>>k2>>k3;
for(int i=1;i<=k1;++i){
cin>>a[i];
++cnt1[a[i]];
}
for(int i=1;i<=k2;++i){
cin>>b[i];
++cnt2[b[i]];
}
for(int i=1;i<=k3;++i){
cin>>c[i];
++cnt3[c[i]];
}
int n=k1+k2+k3;
for(int i=1;i<=n;++i){
cnt1[i]=cnt1[i-1]+cnt1[i];//小于等于i的个数
cnt2[i]=cnt2[i-1]+cnt2[i];
cnt3[i]=cnt3[i-1]+cnt3[i];
}
for(int i=0;i<=n;++i)
mn[i]=cnt3[i]-cnt2[i];
for(int i=n-1;i>=0;--i)
mn[i]=min(mn[i+1],mn[i]);
int ans=1e9;
for(int i=0;i<=n;++i)
ans=min(ans,cnt2[i]-cnt1[i]+mn[i]+cnt1[n]+cnt2[n]);
/*
假设最终状态为第一个人有0~i,第二个人有i+1~j,第三个人有j+1~n
那么最小操作数等于第二个人和第三个人拥有的1~i个数加上第一个人和第三个人拥有的i+1~j个数加上第一个人和第二个人拥有的j+1~n个数
即cnt2[i]+cnt3[i]+cnt1[j]-cnt1[i]+cnt3[j]-cnt3[i]+cnt1[n]-cnt1[j]+cnt2[n]-cnt2[j]
化简为cnt2[i]-cnt1[i]+cnt3[j]-cnt2[j]+cnt1[n]+cnt2[n]
从0到n枚举i,只剩下cnt3[j]-cnt2[j]一个变量
维护一个后缀数组mn[i]表示[i,n]中最小的cnt3[j]-cnt2[j]
*/
cout<<ans;
return 0;
}
Educational Codeforces Round 76 (Rated for Div. 2)E(最长上升子序列)的更多相关文章
- Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest
Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest(dp+线段树) 题目链接 题意: 给定3个人互不相同的多个数字,可以 ...
- Educational Codeforces Round 76 (Rated for Div. 2)E(dp||贪心||题解写法)
题:https://codeforces.com/contest/1257/problem/E 题意:给定3个数组,可行操作:每个数都可以跳到另外俩个数组中去,实行多步操作后使三个数组拼接起来形成升序 ...
- Educational Codeforces Round 76 (Rated for Div. 2)
传送门 A. Two Rival Students 签到. Code /* * Author: heyuhhh * Created Time: 2019/11/13 22:37:26 */ #incl ...
- Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest dp
E. The Contest A team of three programmers is going to play a contest. The contest consists of
- Educational Codeforces Round 76 (Rated for Div. 2) D. Yet Another Monster Killing Problem 贪心
D. Yet Another Monster Killing Problem You play a computer game. In this game, you lead a party of
- Educational Codeforces Round 76 (Rated for Div. 2) C. Dominated Subarray 水题
C. Dominated Subarray Let's call an array
- Educational Codeforces Round 76 (Rated for Div. 2) B. Magic Stick 水题
B. Magic Stick Recently Petya walked in the forest and found a magic stick. Since Petya really likes ...
- Educational Codeforces Round 76 (Rated for Div. 2) A. Two Rival Students 水题
A. Two Rival Students There are
- Educational Codeforces Round 76 (Rated for Div. 2) D题
题意: 给你n个关卡,每个关卡有一个怪物,怪物的攻击力为a[i],你有n个英雄,每个英雄有一个攻击力,和疲劳值,只要英雄的攻击力比怪物的高就算打过了,同时疲劳减一,一天只能出战一个英雄,一个英雄可以打 ...
- Educational Codeforces Round 76 (Rated for Div. 2) D
D题 原题链接 题意:就是给你n个怪兽有一个属性(攻击力),m个英雄,每个英雄有两种属性(分别为攻击力,和可攻击次数),当安排最好的情况下,最少的天数(每选择一个英雄出战就是一天) 思路:因为怪兽是不 ...
随机推荐
- CentOS 7 yum配置阿里云镜像(转)
1.下载源配置 凡是下载国外的软件,比如用npm,pip,yum有时下载速度感人,最好配置国内镜像地址 yum配置阿里云镜像参考:https://blog.csdn.net/hnmpf/article ...
- 题解 P1203 【[USACO1.1]坏掉的项链Broken Necklace】
[USACO1.1]坏掉的项链Broken Necklace 22892 破碎的项链 方法一:很容易想到枚举断点,再分别两头找,但是要注意很多细节 #include<iostream> # ...
- 512,a标签的target属性
<a> 标签的 target 属性规定在何处打开链接文档. 1.“_blank”的意思: 浏览器总在一个新打开.未命名的窗口中载入目标文档. 2.“_parent”的意思: 这个目标,使得 ...
- 转载:Bass management
https://kenrockwell.com/audio/bass-management.htm https://www.axiomaudio.com/blog/bassmanagement htt ...
- python numpy中sum()时出现负值
import numpy a=numpy.random.randint(1, 4095, (5000,5000)) a.sum() 结果为负值, 这是错误的,a.sum()的类型为 int32,如何做 ...
- 全网最全!小白搭建hexo+Github/Gitee/Coding
Hexo是一个快速.简洁且高效的博客框架.Hexo使用Markdown解析文章,在几秒内,即可利用靓丽的主题生成静态网页. 本站内容已全部转移到https://www.myyuns.ltd,具体请移步 ...
- ASP.NET Core Web API 控制器与方法返回输出
DATA ACCESS LAYER 在一些不同的示例教程中,我们可能看到 DAL 的实现在主项目中,并且每个控制器中都有实例.我们不建议这么做. 当我们编写 DAL 时,我们应该将其作为一个独立的服务 ...
- Demo:基于 Flink SQL 构建流式应用
Flink 1.10.0 于近期刚发布,释放了许多令人激动的新特性.尤其是 Flink SQL 模块,发展速度非常快,因此本文特意从实践的角度出发,带领大家一起探索使用 Flink SQL 如何快速构 ...
- AcWing 861. 二分图的最大匹配 匈牙利算法
#include <cstring> #include <iostream> #include <algorithm> using namespace std; , ...
- MySQL 学习(二)总体框架 & redo-log 和 bin-log 的介绍
文章部分总结来自课程,非原创 MySQL 组织架构 下面这张图就可以解释关于 MySQL 底层的组织架构了. 上面的图可以直观地展示两个重要的东西 : 一条 SQL 的执行流程 MyS ...