I. The old Padawan

Time limit: 0.5 second
Memory limit: 64 MB
Yoda: Use the Force. Yes. Now, the stone. Feel it. Concentrate!
Luke Skywalker is having exhausting practice at a God-forsaken planet Dagoba. One of his main difficulties is navigating cumbersome objects using the Power. Luke’s task is to hold several stones in the air simultaneously. It takes complete concentration and attentiveness but the fellow keeps getting distracted.
Luke chose a certain order of stones and he lifts them, one by one, strictly following the order. Each second Luke raises a stone in the air. However, if he gets distracted during this second, he cannot lift the stone. Moreover, he drops some stones he had picked before. The stones fall in the order that is reverse to the order they were raised. They fall until the total weight of the fallen stones exceeds k kilograms or there are no more stones to fall down.
The task is considered complete at the moment when Luke gets all of the stones in the air. Luke is good at divination and he can foresee all moments he will get distracted at. Now he wants to understand how much time he is going to need to complete the exercise and move on.

Input

The first line contains three integers: n is the total number of stones, m is the number of moments when Luke gets distracted and k (1 ≤ n, m ≤ 105, 1 ≤ k ≤ 109). Next n lines contain the stones’ weights wi (in kilograms) in the order Luke is going to raise them (1 ≤ wi ≤ 104). Next m lines contain moments ti, when Luke gets distracted by some events (1 ≤ ti ≤ 109, ti < ti+1).

Output

Print a single integer — the number of seconds young Skywalker needs to complete the exercise.

Sample

input output
5 1 4
1
2
3
4
5
4
8

Hint

In the first three seconds Luke raises stones that weight 1, 2 and 3 kilograms. On the fourth second he gets distracted and drops stones that weight 2 and 3 kilograms. During the next four seconds he raises all the four stones off the ground and finishes the task.
Problem Author: Denis Dublennykh (prepared by Egor Shchelkonogov)
 
#include <iostream>
#include <stdio.h>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <stack>
#include <math.h>
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#pragma comment(linker, "/STACK:10240000000000,10240000000000")
using namespace std;
typedef long long LL ;
const int Max_N= ;
int stone[Max_N] ;
int T[Max_N] ,N ,M ,k ;
int Sum_st[Max_N] ;
int find_id(int id){
int Left ,Right ,Mid ,ans;
if(Sum_st[]-Sum_st[id+]<=k)
return ;
Left= ;
Right=id ;
while(Left<=Right){
Mid=(Left+Right)>> ;
if(Sum_st[Mid]-Sum_st[id+]>k){
ans=Mid ;
Left=Mid+ ;
}
else
Right=Mid- ;
}
return ans- ;
}
int gao(){
int stone_j= ,sum ,ans= ;
T[]= ;
for(int i=;i<=M;i++){
/* for(int t=1;t<=T[i]-T[i-1]-1;t++){
stone_j++ ;
ans++ ;
if(stone_j==N)
return ans ;
}*/
stone_j+=(T[i]-T[i-]-) ;
ans+=(T[i]-T[i-]-) ;
if(stone_j>=N)
return ans-(stone_j-N) ;
stone_j=find_id(stone_j) ;
ans++ ;
}
if(stone_j<N)
return ans+N-stone_j ;
}
int main(){
while(scanf("%d%d%d",&N,&M,&k)!=EOF){
for(int i=;i<=N;i++)
scanf("%d",&stone[i]) ;
Sum_st[N+]= ;
for(int i=N;i>=;i--)
Sum_st[i]=Sum_st[i+]+stone[i];
for(int i=;i<=M;i++)
scanf("%d",&T[i]) ;
printf("%d\n",gao()) ;
}
return ;
}

NEERC 2013, Eastern subregional contest的更多相关文章

  1. NEERC 2014, Eastern subregional contest

    最近做的一场比赛,把自己负责过的题目记一下好了. Problem B URAL 2013 Neither shaken nor stirred 题意:一个有向图,每个结点一个非负值,可以转移到其他结点 ...

  2. NEERC 2010, Eastern subregional contest

    只能把补了的题目放这儿了,先留个坑,怕忘记. Problem G URAL 1806 Mobile Telegraphs 题意是:给定n个电话号码,每个号码是一个长度为10的仅含'0'~'9'的字符串 ...

  3. 2013-2014 ACM-ICPC, NEERC, Eastern Subregional Contest PART (8/10)

    $$2013-2014\ ACM-ICPC,\ NEERC,\ Eastern\ Subregional\ Contest$$ \(A.Podracing\) 首先枚举各个折现上的点,找出最小宽度,然 ...

  4. 2014-2015 ACM-ICPC, NEERC, Eastern Subregional Contest Problem G. The Debut Album

    题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229669 时间限制:1s 空间限制:64MB 题目大意:给定n,a,b的值 求一个长度为n的 ...

  5. 2014-2015 ACM-ICPC, NEERC, Eastern Subregional Contest Problem H. Pair: normal and paranormal

    题目链接:http://codeforces.com/group/aUVPeyEnI2/contest/229669 时间限制:1s 空间限制:64MB 题目大意:给定一个长度为2n,由n个大写字母和 ...

  6. 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror) in codeforces(codeforces730)

    A.Toda 2 思路:可以有二分来得到最后的数值,然后每次排序去掉最大的两个,或者3个(奇数时). /************************************************ ...

  7. 【2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest D】---暑假三校训练

    2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest D Problem D. Distribution in Metagonia Input ...

  8. 2018-2019 ICPC, NEERC, Southern Subregional Contest

    目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...

  9. 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest, qualification stage

    2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest, qualification stage A. Union of Doubly Link ...

随机推荐

  1. JQuery移除事件

    移除事件 unbind(type [,data])     //data是要移除的函数 $('#btn').unbind("click"); //移除click $('#btn') ...

  2. LitDB文章

    阅读目录 1.LiteDB初步介绍 2.LiteDB使用基本案例 3.LiteDB的技术细节 4.资源其他 今天给大家介绍一个不错的小巧轻量级的NoSQL文件数据库LiteDB.本博客在2013年也介 ...

  3. NOIP第7场模拟赛题解

    NOIP模拟赛第7场题解: 题解见:http://www.cqoi.net:2012/JudgeOnline/problemset.php?page=13 题号为2221-2224. 1.car 边界 ...

  4. 【linux】之安装mysql常用配置

    下载mysql地址 http://dev.mysql.com/downloads/mysql/ 选择下面这个 查看是否存在mysql安装包 rpm -qa|grep -i mysql 删除mysql安 ...

  5. insmod module_param 模块参数

    模块参数 引导模块时,可以向它传递参数.要使用模块参数加载模块,这样写: insmod module.ko [param1=value param2=value ...] 为了使用这些参数的值,要在模 ...

  6. vs 引用sqlite的问题

    错误 4 未能找到类型或命名空间名称“SQLiteCommand”(是否缺少 using 指令或程序集引用?) D:\01学习\SQLite\HBZCSCXT_Mobile\SqlLiteHelper ...

  7. 75. Sort Colors

    Given an array with n objects colored red, white or blue, sort them so that objects of the same colo ...

  8. scala高级内容(一) Case Class

    一. 操作符 自定义操作符 操作付默认左结合调用.除了以:结尾的操作符是右结合调用 object OperaterTest extends App{ val a: myInt = new myInt( ...

  9. pthread_key_t和pthread_key_create()详解

    pthread_key_t和pthread_key_create()详解 下面说一下线程中特有的线程存储, Thread Specific Data .线程存储有什么用了?他是什么意思了?大家都知道, ...

  10. WLS_Oracle Weblogic安装和环境搭建(案例)

    2014-01-03 Created By BaoXinjian