Yahoo Programming Contest 2019 D - Ears
思路:

s:起点 t:终点 l:左端点 r:右端点
以上称为关键点
dp[i][j]表示到位置 i 为止,已经经过前 j 个关键点的最小花费
转移方程看代码:
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head const int N = 2e5 + ;
LL dp[N][];
int a[N];
int main() {
int n;
scanf("%d", &n);
for (int i = ; i <= n; ++i) scanf("%d", &a[i]);
for (int i = ; i <= n; i++) {
dp[i][] = dp[i-][] + a[i];
for (int j = ; j < ; j++) {
dp[i][j] = dp[i-][j];
for (int k = ; k < j; k++) dp[i][j] = min(dp[i][j], dp[i-][k]);
}
dp[i][] += a[i] == ? : (a[i]% != );
dp[i][] += a[i]% != ;
dp[i][] += a[i] == ? : (a[i]% != );
dp[i][] += a[i];
}
LL ans = dp[n][];
for (int i = ; i < ; i++) ans = min(ans, dp[n][i]);
printf("%lld\n", ans);
return ;
}
Yahoo Programming Contest 2019 D - Ears的更多相关文章
- Yahoo Programming Contest 2019.D.Ears(DP)
题目链接 菜爆了啊QAQ 记起点为\(S\),终点为\(T\),走过的最靠左的点是\(L\),最靠右的点是\(R\). 那么坐标轴被分成了五段: \(0\sim L-1\):经过\(0\)次: \(L ...
- [AtCoder] Yahoo Programming Contest 2019
[AtCoder] Yahoo Programming Contest 2019 很遗憾错过了一场 AtCoder .听说这场是涨分场呢,于是特意来补一下题. A - Anti-Adjacency ...
- Yahoo Programming Contest 2019 补题记录(DEF)
D - Ears 题目链接:D - Ears 大意:你在一个\(0-L\)的数轴上行走,从整数格出发,在整数格结束,可以在整数格转弯.每当你经过坐标为\(i-0.5\)的位置时(\(i\)是整数),在 ...
- 【AtCoder】Yahoo Programming Contest 2019
A - Anti-Adjacency K <= (N + 1) / 2 #include <bits/stdc++.h> #define fi first #define se se ...
- Atcoder Yahoo Programming Contest 2019 简要题解
A-C 直接放代码吧. A int n,k; int main() { n=read();k=read(); puts(k<=(n+1)/2?"YES":"NO&q ...
- Yahoo Programming Contest 2019
A - Anti-Adjacency 签. #include <bits/stdc++.h> using namespace std; int main() { int n, k; whi ...
- Yahoo Programming Contest 2019 自闭记
A:签到. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> ...
- Yahoo Programming Contest 2019.E.Odd Subrectangles(思路 线性基)
题目链接 \(Description\) 给定一个\(n\times m\)的\(01\)矩阵.求任意选出\(r\)行.\(c\)列(共\(2^{n+m}\)种方案),使得这\(r\)行\(c\)列的 ...
- Yahoo Programming Contest 2019.F.Pass(DP)
题目链接 惊了这是什么F题...怎么我都能做出来...以后atcoder的比赛也不能走神了万一有个这样的F呢(CF已有多次了= =) \(f[i][j]\)表示Takahashi现在一共有\(i\)个 ...
随机推荐
- CVE-2017-8912 CMS Made Simple命令执行
CVE-2017-8912 CMS Made Simple命令执行 1)了解命令执行漏洞,并且能够从源码中发现. 2)用eval处理函数,并且过滤不严导致命令执行. 实验步骤 1.1)登录网站 1.2 ...
- ASP.NET Core ResponseCaching:基于 VaryByHeader 定制缓存 Key
ASP.NET Core ResponseCaching 提供了缓存http响应内容的能力,通过它可以在本地内存中直接缓存http响应内容,这是速度最快的服务端缓存,省却了网络传输与生成响应内容的开销 ...
- 《Mysql 分区分表》
一:分区/分表 为了什么? - 当MySQL单表的数据量过大时,数据库的访问速度会下降,需要处理大量数据,所以需要把数据分散存储. - 常用 "水平" 切分 二:MySQL常见的水 ...
- 【UML】NO.53.EBook.5.UML.1.013-【UML 大战需求分析】- 组合结构图(Composition Structure Diagram)
1.0.0 Summary Tittle:[UML]NO.52.EBook.1.UML.1.012-[UML 大战需求分析]- 交互概览图(Interaction Overview Diagram) ...
- ignore_user_abort(true); set_time_limit(0);程序在本地测试可以一直运行,上传服务器只能运行10-15分钟
当PHP运行在安全模式下时此函数无效.除了关闭安全模式或者在php.ini程序中修改最大运行时间没有其他办法让此函数运行. php.ini 中缺省的最长执行时间是 30 秒,这是由 php.ini 中 ...
- XgBoost推导与总结
一 .机器学习算法中GBDT和XGBOOST的区别有哪些?(转自知乎https://www.zhihu.com/question/41354392/answer/98658997) xgboost相比 ...
- thymeleaf 添加语法提示
thymeleaf 添加语法提示: xmlns:th="http://www.thymeleaf.org"
- shell中wait命令详解
wait命令介绍 wait [作业指示或进程号] 1.等待作业号或者进程号制定的进程退出,返回最后一个作业或进程的退出状态状态.如果没有制定参数,则等待所有子进程的退出,其退出状态为0. 2.如果是s ...
- centos crash debug
https://www.dedoimedo.com/computers/crash.html#mozTocId484074 http://people.redhat.com/anderson/cras ...
- GoldenGate使用SQLEXEC和GETVAL实现码表关联
使用OGG中的SQLEXEC参数,可以执行SQL语句或存储过程,再加上@GETVAL函数,可以在目标端获取源表没有的字段值.比如,源端有一个事实表和一个代码表COUNTRY_CODES,代码表中有两个 ...