ural 1998 The old Padawan
先预处理每一个点往前退几步
就一个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相关推荐
- Ural 1998 The old Padawan(二分)
点击打开题目链接 1998. The old Padawan Time limit: 0.5 second Memory limit: 64 MB Yoda: Use the Force. Yes. ...
- URAL 1998 The old Padawan 二分
The old Padawan 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1998 Description Yoda: Use th ...
- URAL 1998 The old Padawan
题目只给了500ms,注意超时问题,一开始的几发都超时了,后来想到了预处理,从后往前推即可,为了防止t的大小可能有问题,所以进行了排序,还有人用二分做的,比较犀利先贴一个我的思路 #include&l ...
- ural 1998 The old Padawan (模拟+二分)
题意: 有一个人捡按一定顺序捡石头,每秒都能捡起一个,但是他有时会分心,这是不但不能举石头, 而且手中的石头还会掉,直到没有石头可以掉下来或者掉下来的石头的总重量>k.依次给出n个 石头的重量和 ...
- Ural 1018 (树形DP+背包+优化)
题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=17662 题目大意:树枝上间连接着一坨坨苹果(不要在意'坨'),给 ...
- 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 ...
- URAL 1635 Mnemonics and Palindromes
URAL 1635 思路:区间dp+贪心,先n^2处理出每段区间是否是回文串,然后贪心地找每一段1到i的最少分割. 代码: #include<bits/stdc++.h> using na ...
- AGI:走向通用人工智能的【哲学】之现实世界的虚拟与真实——带你回看1998年的经典影片《The Truman Show》感悟“什么是真实”
AGI:走向通用人工智能的[哲学]之现实世界的虚拟与真实--带你回看1998年的经典影片<The Truman Show>感悟"什么是真实" 导读:今天写的这篇文章,完 ...
- [代码]ural 1655 Somali Pirates
Abstract ural 1655 Somali Pirates dp Source http://acm.timus.ru/problem.aspx?space=1&num=1655 So ...
最新文章
- c语言输入函数有什么作用,c语言的输入函数有哪些
- Python 绘图库 Matplotlib
- all()与any()
- AcWing 1303. 斐波那契前 n 项和
- CORS预检请求详谈
- 打开eclipse报错 Version 1.7.0_80 of JVM is not suitable for this product
- 韩国军事网络指挥中心遭到网络攻击
- 《菜菜的机器学习sklearn课堂,tomcat架构解析pdf
- 魔方优化大师 v5.15 中文绿色版
- 操作系统-信号量机制;用信号量机制实现进程互斥、同步、前驱关系
- cad修改快捷键_人手一份的绘图命令,CAD绘图必备,学会工资上万不是梦
- java的跨平台特性是指_如何理解JAVA的跨平台特性
- ubuntu解决浏览器不支持HTML5播放器的方法
- PyTorch—torch.utils.data.DataLoader 数据加载类
- Android so文件函数加密
- 基于深度卷积神经网络(D-CNN)的图像去噪方法
- 专题一:Labview表格控件 及 应用(一)
- Python网络爬虫入门(五)—— 巧用抓包,爬遍SCU玻璃杯事件所有神回复
- 计算机究竟还能火多久
- Tomcat在指定JDK版本启动