设为首页 加入收藏

TOP

(校赛)URAL 1998 The old Padawan
2015-07-20 18:02:41 来源: 作者: 【 】 浏览:2
Tags:校赛 URAL 1998 The old Padawan
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 w i (in kilograms) in the order Luke is going to raise them (1 ≤ w i ≤ 104). Next m lines contain moments t i, when Luke gets distracted by some events (1 ≤ t i ≤ 109, t i < t i+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

今天看到了二分方法,好犀利。。
#include
   
    
#include
    
      #include
     
       #include
      
        #include
       
         using namespace std; const int maxn=1e5; int T[maxn],a[maxn],sum[maxn]; int n,t,k; int solve(int x)//二分得大于x的最小位置i { int l=0,r=n; int ans; while(l<=r) { int mid=(l+r)>>1; if(sum[mid]
        
         >n>>t>>k) { sum[0]=0; for(int i=1;i<=n;i++) { cin>>a[i]; sum[i]=sum[i-1]+a[i]; } for(int i=1;i<=t;i++) cin>>T[i];//第几秒 t++; T[t]=2000000000;//最后没有分心时间的时候可以做if语句做完事情 int pos=0,to; int ans=0; for(int i=1;i<=t;i++) { if(n-pos
         
          

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇网络最大流增广路模板(EK & D.. 下一篇UVA 156 Ananagrams 关于二维数组..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: