超车这个东西这么恶心肯定是要暴力求的(自圆其说)

那么分成一个个时间段来搞,然后DP一下

化一下那个速度,耗费时间是在300s~600s之间的

那我们就可以设f[i][j]为走到第i个位置用了j的时间相遇的最小值

这里有个坑点,就是出发时间和到达时间均相等的两辆车也算相遇。。。

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(''<=ch&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int readtime()
{
int ret=;
for(int i=,b=;i<=;i++,b/=)
{
int k=;char ch;ch=getchar();
while(ch<''||ch>'')ch=getchar();
k=ch-'';ch=getchar();k=k*+ch-'';
ret+=k*b;
}
return ret;
}
void writetime(int T)
{
int k=T/;T-=k*;
if(k<)printf("");
printf("%d",k); k=T/;T-=k*;
if(k<)printf("");
printf("%d",k); if(T<)printf("");
printf("%d\n",T);
} //----------------------------------------------------------------------------------------------------- struct car
{
int st,t;
car(){}
car(int ST,int T){st=ST,t=T;}
}c[];int L[],R[];
int f[][];
int main()
{
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
int n,m,x,st,t;
n=read(),m=read();
for(int i=;i<=n;i++)L[i]=m+;
for(int i=;i<=m;i++)
{
x=read(),c[i].st=readtime(),c[i].t=read();
if(L[x]==m+)L[x]=i;
R[x]=i;
} memset(f,,sizeof(f));f[][]=;
for(int i=;i<n;i++)
for(int j=;j<;j++)
if(f[i][j]!=f[][])
{
for(int k=;k<=;k++)
{
if(j+k>=)break;
int sum=;
for(int l=L[i];l<=R[i];l++)
if((j+k==c[l].st+c[l].t)||(j<c[l].st&&j+k>=c[l].st+c[l].t)||(j>c[l].st&&j+k<=c[l].st+c[l].t))sum++;
f[i+][j+k]=min(f[i+][j+k],f[i][j]+sum);
}
} int mmin=(<<),T;
for(int j=;j<;j++)
if(f[n][j]<mmin)mmin=f[n][j],T=j;
printf("%d\n",mmin);
writetime(T);
return ;
}

bzoj2538: [Ctsc2000]公路巡逻的更多相关文章

  1. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  2. 别人整理的DP大全(转)

    动态规划 动态规划 容易: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ...

  3. dp题目列表

    此文转载别人,希望自己能够做完这些题目! 1.POJ动态规划题目列表 容易:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 11 ...

  4. poj 动态规划题目列表及总结

    此文转载别人,希望自己能够做完这些题目! 1.POJ动态规划题目列表 容易:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 11 ...

  5. poj动态规划列表

    [1]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 13 ...

  6. POJ 动态规划题目列表

    ]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322 ...

  7. poj 动态规划的主题列表和总结

    此文转载别人,希望自己可以做完这些题目. 1.POJ动态规划题目列表 easy:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, ...

  8. 别人整理的dp题目

    动态规划 动态规划 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322, 14 ...

  9. [SinGuLaRiTy] 动态规划题目复习

    [SinGuLaRiTy-1026] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. [UVA 1025] A Spy in the Metr ...

随机推荐

  1. 使用JS获取request参数

    1.document.write('<%=request.getAttribute("param")%>'); 2.window.navigator.userAgent ...

  2. react 返回上一页

    import * as React from 'react' import { Layout } from 'antd'; import creatHistory from 'history/crea ...

  3. 低版本ie兼容问题的解决方案

    CSS hack \9    所有的IE10及之前 *     IE7以及IE7以下版本的 _     IE6以及IE6以下版本的      !important  提升样式优先级权重 1.ie6,7 ...

  4. enote笔记法的思考

    章节:enote笔记法的思考   why enote笔记法: key1)大脑喜欢颜色. 我们的大脑天生就喜欢颜色.对颜色很敏感,这是由我们人类过去的演化历程决定的. 你可以理解为,文字有了颜色,让这个 ...

  5. 洛谷——P1229 遍历问题

    P1229 遍历问题 题目描述 我们都很熟悉二叉树的前序.中序.后序遍历,在数据结构中常提出这样的问题:已知一棵二叉树的前序和中序遍历,求它的后序遍历,相应的,已知一棵二叉树的后序遍历和中序遍历序列你 ...

  6. 面试:B

    协程 材质和贴图 任意模块的深入理解

  7. Volume 6. Mathematical Concepts and Methods

    138 - Street Numbers #include <stdio.h> //(2n+1)^2 - 8m^2 = 1,佩尔函数,或者打表 int main() { ; , xi = ...

  8. accept阻塞

    一直以来以为accept阻塞的时候,若另有线程关闭相应的监听套接字,accept会立即返回. 今天先是在NDK上试,没反应.又在ARCHLINUX试了下,还是没反应.难道是我一直记的都是错的!!!!! ...

  9. HDU - 6158 The Designer

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6158 本题是一个计算几何题——四圆相切. 平面上的一对内切圆,半径分别为R和r.现在这一对内切圆之间,按 ...

  10. [ural1057][Amount of Degrees] (数位dp+进制模型)

    Discription Create a code to determine the amount of integers, lying in the set [X; Y] and being a s ...