跳到正文

题解

题解:P13692 [CEOI 2025] lawnmower

mi_ta约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年8月12日
收录
2025年12月12日
更新
2026年10月28日
篇幅
约 1 分钟
题目
P13692

版本

  1. v1当前

Vlad 拥有一台容量为 的割草机,需要按顺序割完 条割草道。每条割草道 有 的草量,经过该道需要 秒。割草机的收集箱容量为 ,当收集箱满时,必须在该道末端清空,清空需要 秒。割草完成后还需清空一次。Vlad 可以选择在任意时刻提前清空收集箱,以优化总时间。

C++
long long mow(int n, int c, int b, std::vector<int> &a, std::vector<int> &v) {
   long long total_time = 0;
   int current = 0; // 当前收集箱的草量
   for (int i = 0; i < n; i++) {
       // 割草当前道
       total_time += a[i];
       current += v[i];
       if (current > c) {
           // 需要清空
           total_time += b;
           current = v[i]; // 清空后,当前道的草量为 v[i]
       }
   }
   // 最后清空一次
   total_time += b;
   return total_time;
}

以上是伪代码… 代码就不占了,以防某些人借鉴

管理员大大求过@w@

原文