PAT A1033. To Fill or Not to Fill (25)

【100%通过率】华为od统一考试B卷【查找接口成功率最优时间段】Python 实现 服务之间交换的接口成功率作为服务调用关键质量特性,某个时间段内的接口失败率使用一个数组表示,数组中每个元素都是单位时间内失败率数值,数组中的数值为0~100的整数, 给定一个数值(minAverageLost)表示某个时间段内平均失败率容忍值,即平均失败率小于等于minAverageLost,找出数组中最长时间段,如果未找到则直接返回NULL。 阅读详情

题目链接

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.

Input Specification:

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.

Output Specification:

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.

Sample Input 1:
50 1300 12 8
6.00 1250
7.00 600
7.00 150
7.10 0
7.20 200
7.50 400
7.30 1000
6.85 300
Sample Output 1:
749.17
Sample Input 2:
50 1300 12 2
7.10 0
7.00 600
Sample Output 2:
The maximum travel distance = 1200.00

AC代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
struct Sta {
    double price, distance;
}sta[505];
bool cmp(Sta a, Sta b) {
    return a.distance < b.distance;
}
int main() {
    double tank, dis, davg;
    int n;
    scanf("%lf%lf%lf%d", &tank, &dis, &davg, &n);
    for (int i = 0; i < n; i++) {
        scanf("%lf%lf", &sta[i].price, &sta[i].distance);
    }
    //如果不采取其他措施,则这一步必不可少,否则会在第4检查点出错
    //因为一直在比较maxdis之间的station的油价,当price为0时显然最低
    //所以,设置destination的price为0
    //利用这种方法则显得十分便利
    sta[n].price = 0;
    sta[n].distance = dis;
    bool finish = true;
    sort(sta, sta + n, cmp);
    if (sta[0].distance != 0) {
        printf("The maximum travel distance = 0.00");
        return 0;
    }
    double maxdis = davg*tank, nowtank = 0.0, sum = 0.0, money = 0.0;
    int info , now = 0;
    const double MIN = 1<<31-1;
    while (sum < dis) {
        double minprice = MIN;
        bool lower = false;
        info = -1;
        int i = now+1;
        double nowdis = sta[now].distance;
        while (i<=n&&sta[i].distance-nowdis <= maxdis) {
            if (minprice > sta[i].price) {
                minprice = sta[i].price;
                info = i;
                if (minprice < sta[now].price) {
                    lower = true;
                    break;
                }
            }
            i++;
        }
        if (info==-1) {
            if (dis - sta[now].distance <= maxdis) {
                double need = (dis-sta[now].distance) / davg;//油
                if (nowtank < need) {
                    money += (need - nowtank)*sta[now].price;
                }
            }
            else {
                finish = false;
                sum += maxdis;
            }
            break;
        }
        if (lower) {
            double need = (sta[info].distance-nowdis) / davg;//油
            if (nowtank < need) {
                money += (need - nowtank)*sta[now].price;
                nowtank = 0;//到达下一站之后所剩的油量
            }
            else {
                nowtank -= need;
            }
            sum = sta[info].distance;
            now = info;
        }
        else {
            money += (tank - nowtank)*sta[now].price;
            nowtank = tank - (sta[info].distance - nowdis) / davg;
            now = info;
            sum = sta[info].distance;
        }
    }
    if (finish) {
        printf("%.2f",money);
    }
    else {
        printf("The maximum travel distance = %.2f", sum);
    }
    return 0;
}
有部分借鉴于书本,但不全是,所以代码略显臃肿。

YOLOv11-seg 改进系列 | 引入原创 RSCD 重参数共享卷积分割头,增强 Head 表达力并压低计算量 本文提出一种改进的YOLOv11-seg分割头Segment_RSCD,通过重参数共享卷积增强表达能力。该模块在LSCD共享检测头基础上引入DiverseBranchBlock重参数卷积,保留三尺度预测与Proto掩码原型接口不变。相比原始Segment头,Segment_RSCD参数增加4%但计算量降低1.3%,在共享卷积结构中通过多分支补偿表达能力损失,同时利用Scale层保持尺度差异校准。该方法不改动Backbone/Neck结构,仅重构检测/分割头,实现训练期多路径聚合与部署期等效单分支的平衡。 阅读详情

相关推荐

Hand-Eye 标定误差分析:从理论到 C++ 实现

本文深入探讨了机器人手眼标定中的核心环节——误差分析。文章从AX=XB方程的理论残差出发,详细解析了旋转与平移误差的数学定义与物理意义,并提供了一个工业级的C++实现代码,用于计算重投影误差。通过误差分析,工程师可以量化标定精度,诊断问题根源,从而确保视觉引导机器人系统在实际应用中的可靠性与精确性。

c7d8e的博客 697

PAT A 1033 To Fill or Not to Fill (25 分)

一、思路 (一)最低油价方案: 1.若前面有一个价格比本站便宜的油站,那就去那边加更便宜的油,且只在本站加够到达低价油站的油; 2.若前面油站都比本站要贵,说明本站的油是当前最便宜的,要把油加满,下一个目的地的前面一段路上相对最便宜的油站。 (二)逻辑: 有两种情形:下一个目的地是油站,或下一个目的地是终点。 1.下一个目的地是油站的情况: (1)若前方存在价格更便宜的油站,且在可达范围内,且比终...

Siumai's Blog 217

VSCode+PlatformIO新建工程卡成狗?3步提速大法实测有效(附镜像源配置)

针对VSCode+PlatformIO新建工程时因依赖下载缓慢导致的加载慢问题,本文提供了三步核心提速方案。通过配置Python环境变量、修改PlatformIO插件设置以使用国内镜像源,并优化pip配置文件,实测可大幅缩短工程创建时间,有效解决创建工程卡顿的痛点。

delta的博客 717

PAT A1033 To Fill or Not to Fill (25 分) 贪心 模拟

题目大意:给出N个加油站的油费以及距离出发点的距离,汽车油箱有容量上限,求出从出发点到达目的地的最少油费。如果不能到达目的地,输出最远能到达的距离。 个人觉得是相当复杂的一个模拟题,单步跟踪了好几次逻辑才写完整,考察的主要是贪心策略。要点列举如下: ① 目的地也作为一个加油站,油费为0,这样能保证在查找最低油费的加油站时一定能查找到目的地。 ② 在当前所在的加油站往后看,在能...

HackingGate的博客 303

RK3588上rknn_toolkit_lite2报错解决:手把手教你更新librknnrt.so的正确姿势

本文针对在RK3588平台上使用rknn_toolkit_lite2时遇到的“Invalid RKNN model version”等常见错误,提供了完整的诊断与解决方案。文章深入剖析了RKNN生态系统各组件(如librknnrt.so、RKNN Server)版本不兼容的根源,并手把手指导如何安全、正确地更新librknnrt.so运行时库,确保AI模型在RK3588 NPU上实现高效推理。

weixin_29189003的博客 521

博流BL602开发二 环境搭建与固件烧录实战

本文详细介绍了博流BL602 RISC-V芯片开发环境的搭建与固件烧录全流程。从Linux/WSL系统选择、RISC-V工具链配置、SDK获取,到编译首个Wi-Fi示例并生成固件镜像,再到通过命令行或图形化工具完成烧录及串口测试,提供了完整的实战指南和常见问题解决方案。

weixin_29175469的博客 452

PAT A1033 To Fill or Not to Fill (25)

PTA跳转:原题链接 题目大意:给出油箱最大油量,目的地距离,每单位油行驶的路程和加油站数量。再给出某个加油站的单位油价和离起点的距离。输出达到目的地的最小消费。如果不能到达目的地,输出能到达的最远距离。 解题思路:考查贪心算法。每一次行驶,考虑当前状态下加满油能到达的加油站,(1)如果找到比当前油价还低的加油站,把油加到恰好能到达那个加油站即可。(2)如果能到达的每个加油站都比当前加油站的油价高,去能到达的加油站中油价最低的加油站。(3)如果加满油也到达不了下一个加油站,把油用完,输出能行驶的最远距离。

koori_145的博客 182

Unity游戏Mono注入实战:从反编译到功能扩展

本文详细介绍了Unity游戏Mono注入的完整实战流程,从使用dnSpy反编译游戏核心逻辑,到编写自定义C#功能DLL,再到利用SharpMonoInjector进行动态注入。文章深入讲解了如何通过Harmony库拦截修改游戏方法,并介绍了使用MelonLoader框架和UnityExplorer进行高级模组开发与调试,最终通过一个游戏对象透视(ESP)案例演示了功能扩展的实现。

weixin_29018335的博客 461

PAT A1033 To Fill or Not to Fill (25分)

题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805458722734080 题目描述 With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a...

Rhao的博客 260

PLC编程标准之争:IEC61131与IEC61499核心区别与选型指南

在工业自动化领域,PLC编程长期依赖IEC61131标准,它定义了梯形图、结构化文本等语言,通过周期扫描机制保证确定性执行。然而,随着工业4.0和分布式控制场景的兴起,IEC61499以事件驱动模型打破传统范式,让功能块能跨设备协同,实现更灵活的柔性产线和模块化系统。理解两者在程序结构、数据交互、部署方式和实时性上的差异,是选型与工程落地的关键。本文从基础概念出发,剖析执行模型与架构演进,结合一线调试经验,帮助工程师在传统PLC与下一代标准之间做出理性决策。

weixin_27014595的博客 270

LIGGGHTS开源离散元仿真:从基础安装到高级应用实战

本文详细介绍了LIGGGHTS开源离散元仿真软件的基础安装、脚本编写及高级应用实战。从颗粒自由落体模拟到工业级复杂系统建模,涵盖CFD-DEM耦合、高性能计算优化等关键技术,帮助用户快速掌握这一强大的颗粒仿真工具。特别适合需要处理颗粒系统仿真的科研人员和工程师。

l1k9j8h7g6的博客 621

【PAT】A1033 To Fill or Not to Fill (25分)

–题目链接– 总结: 按距离对从小到大对加油站站点排序,另多设一个终点站,其距离为最大距离D,油价为0.0。 核心思路:从当前站点now寻找行程范围内下一站点next: (1)如果行程范围内无站点可达,则加满油跑一个最大行程,结束。 (2)对于行程范围内(加满油可跑的最远距离)可达的站点,从近及远考察:记录最小油价 ①:若一旦出现油价小于当前now站的油价,则该点即为下一站next。并且油箱加到刚好够到这一站。 ②若行程范围内的站点油价都高于now站的油价,则其中油价最小的即为next站(在遍历

jetpack_的博客 183

OpenClaw使用ClawHub安装skill网络不稳定?Rate limit exceeded报错?试试这个国内高速镜像工具!

使用 ClawHub 安装 Skill 时遇到 🌐 网络不稳、❌ Rate limit 或命令不可用?使用这个镜像工具,轻松解决skill安装问题,⚡

XiaoqiangClub的博客 1261

PAT A 甲级 1033 To Fill or Not to Fill (25分)

1033 To Fill or Not to Fill (25分) 吐槽 花了好一会儿才反应过来tank是油箱不是坦克。还以为又battle over cities了。 然后这题目很憨。这测点更憨。当然最憨的还是花了这么久才解决这道题的我。 思路 首先到不了的那种情况,很好处理,只要从距离0的站开始第一次发现两相邻站距离大于满油就输出该站距离+满油箱可走长度即可(测点2坑警告,见之后测点部分)。 ...

虚境的博客 225

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

pat-a1033. To Fill or Not to Fill (25)

这个题就是贪心(还是看了看宝典,2333) 贪心策略:从起点开始,依次往后,找到一个价格比目前加油站单价更低的加油站就只需要买刚好能到该加油站的油就行了。如果在能走的范围内所有加油站的单价都高于目前加油站的单价,直接在目前加油站加油加满,在能到的范围内选一个单价最低的。一直这样走就行 刚开始有个点一直过不了,是我程序思路问题,到了某个加油站后,只要后面还有加油站就一定会选一个加油站,其实有可能

dream_never_giveup的博客 649

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

[PAT] A1033 To Fill or Not to Fill (25分)

(重要!) 贪心 思路 首先将各加油站按照距离进行排序,如果没有距离为0的加油站,则直接输出The maximum travel distance = 0.00;若有则进行下面的判断。 对于每个加油站加多少最为合适?用贪心策略。 设当前我们站在加油站A。 1) 如果在A能到达的最大范围内(即假设在A加满油),有加油站的油价比当前站A的油价低:设距离A最近的且比A小的加油站为B,则加到能恰...

yue的博客 92

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

PAT A1033 To Fill or Not to Fill (25 分)

PAT A1033 To Fill or Not to Fill (25 分) 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 gi

weixin_48165493的博客 170

pat 甲级A1033 To Fill or Not to Fill (25分)

题目链接: https://pintia.cn/problem-sets/994805342720868352/problems/994805458722734080 题目分析: 参考代码: #include <iostream> #include <algorithm> #include <vector> using namespa...

dutmathjc的博客 221

【PAT甲级A1033】To Fill or Not to Fill (25分)(c++)

1033 To Fill or Not to Fill (25分) 作者:CHEN, Yue 单位:浙江大学 代码长度限制:16 KB 时间限制:400 ms 内存限制:64 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

小庄同学的博客 250

PAT A 1033. To Fill or Not to Fill (25)

PAT未AC题

Catcher's blog 423

PAT-A 1033 To Fill or Not to Fill (25 分)

坑点:杭州市内可能没有加油站。也就是说,第一个加油站距离杭州的距离可能不是0 思路:贪心思想,尽量用最便宜的油跑完两个加油站之间的距离。 油箱大小和单位油耗跑的里程数决定了一辆车加满油可以跑的最远的距离。 先将加油站按照距离杭州的距离从小到大进行排序,然后将目的地的油价设置为0,加入到最后一个站点,这样做是效仿带“哨兵”的插入排序,为了减少特判。 首先判断是否可以续航--如果到下一个加油站的距离大于加满油可以跑的最远距离,那么将无法抵达,输出可以行驶到的最远的距离:当前站点的距离加上汽车可以加满油可

qq_38127801的博客 126

PAT-A 1033. To Fill or Not to Fill (25)

贪心解决加油站加油策略问题

Tomorrow Never Knows 623

PAT A1033 To Fill or Not to Fill (25 分)——贪心

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. Dif...

weixin_30598225的博客 95

PAT-A-1033 To Fill or Not to Fill (25 分)贪心算法 C++题解

1033 To Fill or Not to Fill (25 分) 题目传送门:1033 To Fill or Not to Fill (25 分) 一、题目大意 求从杭州站到目的站的最小油费。 杭州站与目的站之间有很多个加油站,每个加油站的油价不同。如果无法到达输出最大行驶距离,否则输出到达目的站的最小油费。 二、解题思路 这道题很明显是贪心算法,但是具体怎么求下一站点,还挺复杂的。 注意:题...

爱玲姐姐的博客 996
上一篇: PAT A1080. Graduate Admission (30)
下一篇: PAT A1037. Magic Coupon (25)
DemonInside
博客等级 码龄10年 1粉丝 18原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值