SSL 1748_飞翔_dp+离散
来源:互联网 发布:模拟投资基金软件 编辑:程序博客网 时间:2024/06/05 02:15
题目描述
这些鹰的起始点被设在一个N*M矩阵的左下角map[1,1]的左下角。终点被设定在矩阵的右上角map[N,M]的右上角,有些map[i,j]是可以从中间穿越的。每一个方格的边长都是100米。如图所示:
思路
离散了以后用最长不下降子序列求解
就是排序一下找到一个有最多特殊路径的上升的路就可以了
#include <stdio.h>#include <algorithm>#include <math.h>using namespace std;struct arr{ int x,y;}a[10000];int f[10000];int camp(arr a,arr b){ if (a.x==b.x) return a.y<b.y; return a.x<b.x; }int main(){ int n,m,l; scanf("%d%d%d",&n,&m,&l); for (int i=1;i<=l;i++) scanf("%d%d",&a[i].x,&a[i].y); sort(a+1,a+l+1,camp); for (int i=1;i<=l;i++) { int t=0; for (int j=0;j<=i;j++) { if (a[j].x<a[i].x&&a[j].y<a[i].y&&f[j]+1>t) t=f[j]+1; } f[i]=t; } int t=0; for (int i=1;i<=l;i++) if (f[i]>t) t=f[i]; printf("%.0lf\n",(n+m-2*t+sqrt(2)*t)*100);}
1 0
- SSL 1748_飞翔_dp+离散
- SSL 2315_打砖块_dp
- SSL 1673_垃圾陷阱_dp
- SSL 1321_幻灯片_离散
- SSL 2250_面积_离散
- 洛谷 1057_传球_dp
- codevs 1086_栈_dp
- jzoj 1279_解题_dp
- 20170910_拼凑钱币_DP
- SSL 1055——能量项链_DP
- hdu_2577_键盘打字_模拟_DP
- 区间_纪中1382_dp
- 方格取数_纪中_dp
- 采药2_纪中2540_dp
- 跳舞_纪中2545_dp
- 删数_纪中3097_dp
- 最大值_纪中1857_dp
- 雾雨魔理沙_纪中2555_dp
- Linux Crontab 设置的定时任务没有启动的排查
- 优先级队列的使用
- Java学习笔记之变量
- Follow me!百万奖金由你拿 | 精准资助数据探索(一)
- 深度学习(六)caffe入门学习
- SSL 1748_飞翔_dp+离散
- 利用UIDocumentInteractionController文档预览以及调用iPhone里第三方相关的app打开文档
- intellij idea 出现 usage search was canceled
- sdeError
- CentOS使用yum命令安装vsftp
- linux下IPTABLES配置详解
- 设计模式之命令模式
- LeetCode学习之路-Longest Substring Without Repeating Characters
- 高德自定义marker