zoukankan      html  css  js  c++  java
  • 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 C: Coconut

    C: Coconut

    time limit

    200ms

    memory limit

    131072KB

    Coconut is Captain Gangplank's favourite fruit. That is why he needs to drink coconut juice from b coconuts each day.

    On his next trip, he would pass through N citis.

    His trip would begin in the 1-st city and end in the N-th city.

    The journey from the i-th city to the (i + 1)-th city costs Di days.

    Initially, there is no coconut on his ship. Fortunately, he could get supply of Ci coconuts from the i-th city.

    Could you tell him, whether he could drink coconut juice every day during the trip no not 

    Input Format

    The first line contains an integer T , indicating that there are T test cases.

    For each test case the first line contains two integers N and b as described above. 

    The second line contains N integers C1, C2,  , CN .

    The third line contains N − 1 integers D1, D2,  , DN−1.

    All integers in the input are less than 1000.

    Output Format

    For each case, output Yes if Captain Gangplank could drink coconut juice every day, and otherwise output No.

    Sample Input

    2

    4 1

    3 2 1 4

    1 2 3

    4 2

    2 4 6 8

    3 2 1

    Sample Output

    Yes

    No

    #include <iostream>
    using namespace std;
    int main()
    {
        int a[2][1000];
        int n,t,b;
        cin>>t;
        while(t--)
        {
            cin>>n>>b;
            for(int i=0;i<n;++i)
                cin>>a[0][i];
            for(int i=0;i<n-1;++i)
                cin>>a[1][i];
            for(int i=0;i<n-1;++i)
            {
                if(a[1][i]*b<=a[0][i])
                  {
                       a[0][i+1]+=a[0][i]-a[1][i]*b;
    
                  }
                else
                {
                    cout<<"No"<<endl;
                    break;
                }
                if(i==n-2)
                    cout<<"Yes"<<endl;
            }
        }
            return 0;
    
    
    }


  • 相关阅读:
    话说打工
    Linux系统信息查看命令大全
    基于LNMP的Zabbbix之Zabbix Server源码详细安装,但不给图
    基于LNMP的Zabbbix之PHP源码安装
    php --with-mysql=mysqlnd
    LeetCode:Binary Tree Level Order Traversal
    tslib-触摸屏校准
    A
    【雷电】源代码分析(二)-- 进入游戏攻击
    能够替代浮动的inline-block
  • 原文地址:https://www.cnblogs.com/sxy201658506207/p/7586277.html
Copyright © 2011-2022 走看看