先利用动态规划求出n个电话后能忽略k电话所能空间时间的最小左边界(哎!!当时还想用贪心,为啥就没想到动态规划呢!!)然后就是一个枚举过程,因为一个休息时间必将以一个电话的到来而结束,枚举4000个电话,然后就ok了!!!!说白了就tm是个水dp!!!太水了!!周五的vk一定会ak!!!
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<cstring>
#include<iomanip>
using namespace std;
#ifdef _WIN32
#define i64 __int64
#define out64 "%I64d\n"
#define in64 "%I64d"
#else
#define i64 long long
#define out64 "%lld\n"
#define in64 "%lld"
#endif
#define FOR(i,a,b) for( int i = (a) ; i <= (b) ; i ++)
#define FF(i,a) for( int i = 0 ; i < (a) ; i ++)
#define FFD(i,a) for( int i = (a)-1 ; i >= 0 ; i --)
#define S64(a) scanf(in64,&a)
#define SS(a) scanf("%d",&a)
#define LL(a) ((a)<<1)
#define RR(a) (((a)<<1)+1)
#define SZ(a) ((int)a.size())
#define PP(n,m,a) puts("---");FF(i,n){FF(j,m)cout << a[i][j] << ' ';puts("");}
#define pb push_back
#define CL(Q) while(!Q.empty())Q.pop()
#define MM(name,what) memset(name,what,sizeof(name))
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
const int inf = 0x3f3f3f3f;
const i64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
const double oo = 10e9;
const double eps = 10e-10;
const double pi = acos(-1.0);
const int maxn = 4444;
int t[maxn],d[maxn];
int dp[maxn][maxn];
int n,k,ans;
int main()
{
while(cin>>n>>k)
{
for(int i=1;i<=n;i++)
{
cin>>t[i]>>d[i];
}
t[n+1]=86401;
d[n+1]=111;
FF(i,maxn) dp[0][i]=1;
int qw,as;
FOR(i,1,n)
{
FOR(j,0,k)
{
qw=dp[i-1][j];
if(qw <= t[i])
{
qw=t[i]+d[i];
}
else
{
qw=qw+d[i];
}
if(j)
{
as=dp[i-1][j-1];
}
else
{
as=inf;
}
dp[i][j]=min(as,qw);
}
}
ans=0;
FOR(i,1,n+1)
{
ans=max(ans,t[i]-dp[i-1][k]);
}
if(n==k)
{
ans=86400;
}
printf("%d\n",ans);
}
return 0;
}
分享到:
相关推荐
自己写的源码,希望各位看官指出不足之处,好交流进步
PDF
GMW 15420-2012 Global Qualification Process for Aluminum Sheet
DO-178C对应的工具鉴定标准,DO-330.DO-330 Software Tool Qualification Considerations Mar 2012
ITIL v3 Qualification
6013E:2021 Qualification and Performance Specification for Flexible-Rigid-Flexible Printed Boards -.rar
AEC Q200 stress test qualification for passive components被动元件汽车级品质认证
Stress-Test-Driven Qualification of Integrated Circuits
完整英文版 IEC 61730-1:2023 Photovoltaic (PV) module safety qualification - Part 1:Requirements for construction(光伏(PV)组件安全资质第1部分:施工要求)。 IEC 61730-1:2023 规定并描述了光伏 (PV) ...
AEC-Q104:2017 Failure Mechanism Based Stress Test Qualification
DNV is a global provider of knowledge for managing risk. Today, safe and responsible business conduct is both a license to operate and a competitive advantage. Our core competence is to identify, as...
JEDEC JEP001-1A:2018 FOUNDRY PROCESS QUALIFICATION GUIDELINES –
java在线答疑源码 Google-Hash-Code-2020-Online-Qualification-Round Score
AEC - Q200 Stress Test Qualification For Passive Components.zip
Tesla Supplier Qualification Assessment( 特斯拉供应商资格评估)
Introductory Certificate The APM Project Fundamentals Qualification Study Guide 英文azw3 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
2020-1 Bluetooth Qualification Program - Test Case Reference List(TCRLs)_2020-01-GATT-Audio_2020-BLP1.1-DTP-PAMP-ATP-CTES-MICP-CCP-TBS-MCP-MCS.zip.zip
Tesla Supplier Qualification Assessment( 特斯拉供应商资格评估).zip
Program and method to charger qualification and reliability test. Guide for engineer fully.
关于GPIOs引脚的自带滤波,类似于按键防抖 qualification_filter_for_the_GPIOs