[11.3]日常模拟.3
来源:互联网 发布:中国家暴数据统计2017 编辑:程序博客网 时间:2024/06/05 09:19
//60 + 0 + 30
//太弱了,这样怎么考试
//(以下只改了T1)
T1
//想到dp的方程了,可惜dp功底太差,不会处理细节
首先可以发现当高度h满足单调性时,h[i] - h[j]最优;
所以可以按h排序
在进行DP
f[i][j]表示跳了i次,到了j点所用的代价和
转移方程为f[i][j] = min(f[i-1][k] + h[j] - h[k] + val[j])
找到满足 <= T的最大的i即可
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn = 100;int n,f[maxn][maxn],t;struct node { int val,h; bool operator < (const node a) const{ return h < a.h; }}e[maxn];int read() { int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); } return x * f;}int main() { freopen("meet.in","r",stdin); freopen("meet.out","w",stdout); n = read(); for(int i = 1; i <= n; i++) e[i].val = read(); for(int i = 1; i <= n; i++) e[i].h = read(); t = read(); sort(e+1,e+1+n); int ans = 0; for(int i = 1; i <= n; i++) { f[0][i] = e[i].val; for(int j = 1; j <= n; j++) { f[j][i] = 1e7; } } for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { for(int k = 1; k < j; k++) { if(f[i-1][k] + e[j].h - e[k].h + e[j].val <= t) { f[i][j] = min(f[i][j],f[i-1][k] + e[j].h - e[k].h + e[j].val); ans = max(ans,i); } } } } cout<<ans + 1; return 0;}
T2
//想过按照a1,a2来暴力枚举,但不会打,早知道就多想一会了(明明是正解
//但赛后没看懂std,只能弃疗了
T3
//据说是什么分块+链表,不想改了
阅读全文
0 0
- [11.3]日常模拟.3
- [11.1]日常模拟.1
- [11.2]日常模拟.2
- [11.6] 日常模拟
- 日常3
- Git日常用法(3)
- oracle 日常维护3
- 程序猿日常-3
- 日常3--ueitor
- 【日常收获3】
- 日常作业3
- 日常总结3
- 日常运维-3
- 日常运维-3
- 日常
- 日常
- 【日常】...
- 日常
- Python安装教程
- Titan数据库快速入门之神的光芒
- HashMap为什么是不安全的?HashTable和ConcurrentHashMap为什么是安全的 ?
- IDEA导出jar包后运行报错 找不到或无法加载主类
- 如何提高SSH的安全性?
- [11.3]日常模拟.3
- LintCode 最长上升连续子序列
- Frida官方手册
- 非线性动力学与混沌
- Nginx+Tomcat搭建高性能负载均衡集群
- 洛谷 1650 赛马 贪心 解题报告
- 基础篇--Unity3D中部分视图的打开方法及一些注释
- 【Unity】Ninja跑酷学习笔记一
- scrip基本操作 拼接 替换 分割.....