codeup

问题 C: To Fill or Not to Fill
[命题人 : 外部导入]
时间限制 : 1.000 sec 内存限制 : 32 MB

题目描述
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are asked to carefully design the cheapest route to go.

输入
Each input file contains one test case. For each case, the first line contains 4 positive numbers: Cmax (<= 100), the maximum capacity of the tank; D (<=30000), the distance between Hangzhou and the destination city; Davg (<=20), the average distance per unit gas that the car can run; and N (<= 500), the total number of gas stations. Then N lines follow, each contains a pair of non-negative numbers: Pi, the unit gas price, and Di (<=D), the distance between this station and Hangzhou, for i=1,…N. All the numbers in a line are separated by a space.

输出
For each test case, print the cheapest price in a line, accurate up to 2 decimal places. It is assumed that the tank is empty at the beginning. If it is impossible to reach the destination, print “The maximum travel distance = X” where X is the maximum possible distance the car can run, accurate up to 2 decimal places.

样例输入 Copy
59 525 19 2
3.00 314
3.00 0
样例输出 Copy
82.89

#include <stdio.h>
#include <algorithm>

using namespace std;

struct station{
    double dis_to_HZ;
    double price;
}St[501];

bool cmp(station a, station b){
    if(a.dis_to_HZ != b.dis_to_HZ) return a.dis_to_HZ < b.dis_to_HZ;
    else return a.price < b.price;
}
int main()
{
    double c, d, d_avg;
    int n;

    while(scanf("%lf%lf%lf%d", &c, &d, &d_avg, &n) != EOF){
        for(int i = 0; i < n; i++) scanf("%lf%lf", &St[i].price, &St[i].dis_to_HZ);

        sort(St, St + n, cmp);

        St[n].dis_to_HZ = d;
        St[n].price = 0;

        double full_gas_len = c * d_avg;
        double dis = 0;
        double fee = 0;
        double gas = 0;
        int flag = 0;

        if(St[0].dis_to_HZ != 0){
            dis = 0;
            flag = 1;
        }
        else{
            for(int i = 0; i < n; i++){
                int flag_no_cheap = 1;
                double cheapst_in_range = St[i + 1].price;
                int cheapst_in_range_index = i + 1;


                if(St[i + 1].dis_to_HZ - St[i].dis_to_HZ > full_gas_len){
                    dis += full_gas_len;
                    flag = 1;
                    break;
                }

                for(int j = i + 1; j <= n && St[j].dis_to_HZ - St[i].dis_to_HZ <= full_gas_len; j++){
                    if(St[j].price < St[i].price){
//                        if(St[j].price < cheapst_in_range){
//                            cheapst_in_range = St[j].price;
//                            cheapst_in_range_index = j;
//                        }
                        dis = dis + St[j].dis_to_HZ - St[i].dis_to_HZ;
                        fee += ((St[j].dis_to_HZ - St[i].dis_to_HZ) / d_avg - gas) * St[i].price;
                        gas = 0;
                        i = j - 1;
                        flag_no_cheap = 0;
                        break;
                    }

                    if(St[j].price < cheapst_in_range){
                            cheapst_in_range = St[j].price;
                            cheapst_in_range_index = j;
                        }
                }

                if(flag_no_cheap){
                    dis = dis + St[cheapst_in_range_index].dis_to_HZ - St[i].dis_to_HZ;
                    fee += (c - gas) * St[i].price;
                    gas = c - (St[cheapst_in_range_index].dis_to_HZ - St[i].dis_to_HZ) / d_avg;
                    i = cheapst_in_range_index - 1;

                }

            }
        }


        if(flag) printf("The maximum travel distance = %.2lf\n", dis);
        else printf("%.2lf\n", fee);

    }


    return 0;
}

### Codeup与Jenkins集成概述 为了实现Codeup仓库同Jenkins之间的集成,确保能够顺利执行持续集成流程,需完成一系列配置工作。这不仅涉及到新建Jenkins任务以及安装必要插件,还涵盖了设置Webhook来触发构建过程。 #### 安装必需的Jenkins插件 在开始之前,需要在Jenkins中安装两个必要的插件:Git源码管理插件和Generic Webhook Trigger插件。打开Jenkins管理界面,点击"系统管理",然后选择"插件管理"。在可选插件中搜索并安装"Git plugin"[^1] 和 "Generic Webhook Trigger Plugin" 。安装完成后,重启Jenkins以使这些新安装的插件生效。 #### 创建新的Jenkins任务并与Codeup关联 创建一个新的自由风格软件项目任务,在源码管理部分选择Git,并填写Codeup项目的URL作为远程仓库地址。对于认证方式,可以采用SSH密钥或HTTPS用户名加Token的方式连接到Codeup仓库[^2]。 #### 设置Webhook触发器 为了让每次向Codeup推送代码变更时都能自动触发展开一次构建操作,应当按照如下方法设定webhook: - 登录至Codeup平台; - 寻找目标仓库页面内的“Settings”选项卡下的Webhooks菜单项; - 添加一条指向`http(s)://<username>:<password>@jenkinsURL/generic-webhook-trigger/invoke`的新记录[^5] ,其中`<username>`、 `<password>`替换为实际访问凭证,而`jenkinsURL`则对应于运行中的Jenkins实例公网入口地址; 通过上述步骤即可建立起从Codeup推送到Jenkins自动化流水线处理的基础架构支持体系。 ```bash # 示例命令用于展示如何下载Maven工具包而非直接参与CI/CD链路搭建 wget https://archive.apache.org/dist/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值