先预处理每一个点往前退几步

就一个trick。。要处理这一秒已经超出了要拿完所花的时间

#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define inf 0x3f3f3f3f
typedef __int64 ll;
using namespace std;int c[100005],w[100005],s[100005],t[100005],tmp,N,n,m,k,i,cnt,pos,ans;int main()
{while(~scanf("%d%d%d",&n,&m,&k)){for(i=1;i<=n;i++)scanf("%d",&w[i]);for(i=1;i<=m;i++)scanf("%d",&t[i]);s[n]=w[n];tmp=n-1;cnt=1;while(s[n]<=k&&tmp>0){s[n]+=w[tmp];tmp--;cnt++;}c[n]=cnt;N=n-1;while(N){s[N]=s[N+1]-w[N+1];cnt--;while(s[N]<=k&&tmp>0){s[N]+=w[tmp];tmp--;cnt++;}c[N]=cnt;// printf("N:%d cnt:%d tmp:%d\n",N,cnt,tmp);if(tmp<=0){for(i=N;i>0;i--){c[i]=i;}break;}N--;}//处理每一个分散注意力的秒sort(t+1,t+m+1);t[0]=0;ans=0;pos=0;for(i=1;i<=m;i++){tmp=(t[i]-t[i-1]);pos+=tmp;if(pos>n){//时间超出了全部拿完的时间pos-=tmp;break;}ans+=tmp;pos=pos-1-c[pos-1];}ans+=(n-pos);printf("%d\n",ans);}return 0;
}

ural 1998 The old Padawan相关推荐

  1. Ural 1998 The old Padawan(二分)

    点击打开题目链接 1998. The old Padawan Time limit: 0.5 second Memory limit: 64 MB Yoda: Use the Force. Yes. ...

  2. URAL 1998 The old Padawan 二分

    The old Padawan 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1998 Description Yoda: Use th ...

  3. URAL 1998 The old Padawan

    题目只给了500ms,注意超时问题,一开始的几发都超时了,后来想到了预处理,从后往前推即可,为了防止t的大小可能有问题,所以进行了排序,还有人用二分做的,比较犀利先贴一个我的思路 #include&l ...

  4. ural 1998 The old Padawan (模拟+二分)

    题意: 有一个人捡按一定顺序捡石头,每秒都能捡起一个,但是他有时会分心,这是不但不能举石头, 而且手中的石头还会掉,直到没有石头可以掉下来或者掉下来的石头的总重量>k.依次给出n个 石头的重量和 ...

  5. Ural 1018 (树形DP+背包+优化)

    题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=17662 题目大意:树枝上间连接着一坨坨苹果(不要在意'坨'),给 ...

  6. bzoj1814 Ural 1519 Formula 1(插头dp模板题)

    1814: Ural 1519 Formula 1 Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 924  Solved: 351 [Submit][S ...

  7. URAL 1635 Mnemonics and Palindromes

    URAL 1635 思路:区间dp+贪心,先n^2处理出每段区间是否是回文串,然后贪心地找每一段1到i的最少分割. 代码: #include<bits/stdc++.h> using na ...

  8. AGI:走向通用人工智能的【哲学】之现实世界的虚拟与真实——带你回看1998年的经典影片《The Truman Show》感悟“什么是真实”

    AGI:走向通用人工智能的[哲学]之现实世界的虚拟与真实--带你回看1998年的经典影片<The Truman Show>感悟"什么是真实" 导读:今天写的这篇文章,完 ...

  9. [代码]ural 1655 Somali Pirates

    Abstract ural 1655 Somali Pirates dp Source http://acm.timus.ru/problem.aspx?space=1&num=1655 So ...

最新文章

  1. c语言输入函数有什么作用,c语言的输入函数有哪些
  2. Python 绘图库 Matplotlib
  3. all()与any()
  4. AcWing 1303. 斐波那契前 n 项和
  5. CORS预检请求详谈
  6. 打开eclipse报错 Version 1.7.0_80 of JVM is not suitable for this product
  7. 韩国军事网络指挥中心遭到网络攻击
  8. 《菜菜的机器学习sklearn课堂,tomcat架构解析pdf
  9. 魔方优化大师 v5.15 中文绿色版
  10. 操作系统-信号量机制;用信号量机制实现进程互斥、同步、前驱关系
  11. cad修改快捷键_人手一份的绘图命令,CAD绘图必备,学会工资上万不是梦
  12. java的跨平台特性是指_如何理解JAVA的跨平台特性
  13. ubuntu解决浏览器不支持HTML5播放器的方法
  14. PyTorch—torch.utils.data.DataLoader 数据加载类
  15. Android so文件函数加密
  16. 基于深度卷积神经网络(D-CNN)的图像去噪方法
  17. 专题一:Labview表格控件 及 应用(一)
  18. Python网络爬虫入门(五)—— 巧用抓包,爬遍SCU玻璃杯事件所有神回复
  19. 计算机究竟还能火多久
  20. Tomcat在指定JDK版本启动

热门文章

  1. postgreSQL与postGIS安装过程中遇到的坑及解决
  2. GIS空间分析 栅格数据分析1 欧氏距离分析
  3. 还没35岁的我已经快秃了
  4. 制造业行业现状及智能生产管理系统一体化解决方案
  5. 从A股暴跌看中国经济发展
  6. 百度人脸识别搜索是怎么实现的?
  7. 2021研面准备 -- 计算机网络知识点整理(一)概述
  8. 软件公司,销售管理门道(七)销售协同
  9. 奥鹏教育微学吧JAVA答案_西交20秋《Java语言》在线作业【标准答案】
  10. 广域网技术——SR技术概括