1 条题解

  • 1
    @ 2024-10-6 17:43:01
    #include<iostream>
    
    using namespace std;
    int main()
    {
    	
    	int n,d;//n站点,d公里/升
    	
    	cin >> n>> d;
    	long long juli[n] = {0};
    	long long jiage[n] = {0};
    	for(int i = 1;i<n;i++)
    	{
    		int tmp; 
    		cin>>tmp;
    		juli[i] = juli[i-1]+tmp;
    	}
    	
    	for(int i = 0;i<n;i++)
    	{
    		cin>>jiage[i];
    	}
    	
    	long long zj = 0;
    	int zhan = 0;
    	long long zjl = 0;
    	int xiazhan = 0;
    	while(zhan < n - 1)
    	{
    		for(xiazhan = zhan + 1;xiazhan < n - 1;xiazhan++)
    		{
    			if(jiage[xiazhan]<jiage[zhan])
    			{	
    				break;
    			}
    		}
    		
    		long long jl = juli[xiazhan] - zjl;
    		long long you = jl / d;
    		if(jl % d != 0)
    		{
    			you++;
    		}
    		zj += you * jiage[zhan];
    		zjl += you * d;
    		zhan = xiazhan;
    	}
    	
    	cout<<zj;
    	
    	return 0;
    }
    
    • 1

    信息

    ID
    2270
    时间
    1000ms
    内存
    512MiB
    难度
    8
    标签
    递交数
    34
    已通过
    5
    上传者