当前位置: 首页 > article >正文

精选一百道备赛蓝桥杯——5.空调

在这里插入图片描述
在这里插入图片描述

差分

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int a[100010], t[100010];
int ad[100010], td[100010];
int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int ans = 0;
    int n; cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> t[i];
    int z = 0, f = 0;
    for(int i = 1; i <= n; i++){
        ad[i] = a[i] - a[i-1];
        td[i] = t[i] - t[i-1];
        if(td[i] - ad[i] > 0) z += td[i] - ad[i];
        else f -= td[i] - ad[i];
    }
    cout << max(z, f);
    return 0;
}

http://www.kler.cn/a/588499.html

相关文章:

  • 鸿蒙(OpenHarmony)开发实现 息屏/亮屏 详情
  • 深度学习 Deep Learning 第1章 深度学习简介
  • 一周热点:法官在人工智能训练版权案中支持版权主张
  • SpringMVC(七)数据校验+VO++脱敏
  • DataWhale 大语言模型 - GPT和DeepSeek模型介绍
  • 弹球小游戏-简单开发版
  • 2.7 滑动窗口专题:串联所有单词的子串
  • Jenkins服务搭建
  • Amazon 全球买卖商品 库存模型
  • Easyexcel操作文件
  • ubuntu-linux-系统用户界面无法显示-弹出报警框!
  • Go语言的数据库分片
  • tkinter快键画布
  • 技术视界|构建理想仿真平台,加速机器人智能化落地
  • Polhemus Patriot 电磁式位置追踪系统空间定位系统
  • SpringBoot 和vue前后端配合开发网页拼图10关游戏源码技术分享
  • Linux操作系统6- 线程3(线程的取消,分离与独立存储)
  • 反射(第三篇)、代理模式、静态代理和动态代理、InvocationHandler实际应用
  • 第十六届蓝桥杯康复训练--2
  • 新手村:数据预处理-缺失值补充策略