CF1763C Another Array Problem
人类智慧题。harmis_yz 不会。
题意
给定一个序列 \(\{a_n\}\),可以进行若干次操作,每次可以选择 \(i,j(1 \le i < j \le n)\),将 \([i,j]\) 之间的数全部变为 \(|a_i - a_j|\),问进行若干次操作后序列之和最大值。
\(\tt{Solution}\)
不容易发现,如果连续对同一对 \(i,j\) 进行两次操作,那么 \([i,j]\) 全为 \(0\)。
然后就做完了。注意需要特判 \(n=2,3\) 的情况,将所有情况取 \(\max\) 即可。
其余情况的答案显然为 \(\max\{a_i\} \times n\)。
CF1763C Another Array Problem的更多相关文章
- Maximum sub array
Here I post a way to solve maximum sub array problem: The problem described like this: here is an ar ...
- codechef AUG17 T1 Chef and Rainbow Array
Chef and Rainbow Array Problem Code: RAINBOWA Chef likes all arrays equally. But he likes some array ...
- HDU 5532 / 2015ACM/ICPC亚洲区长春站 F.Almost Sorted Array
Almost Sorted Array Problem Description We are all familiar with sorting algorithms: quick sort, mer ...
- CodeChef Mahesh and his lost array
Mahesh and his lost array Problem code: ANUMLA Submit All Submissions All submissions for this ...
- scau 2015寒假训练
并不是很正规的.每个人自愿参与自愿退出,马哥找题(马哥超nice么么哒). 放假第一周与放假结束前一周 2015-01-26 http://acm.hust.edu.cn/vjudge/contest ...
- HYNB Contest 7:2017 Asia HCMC Vietnam National Programming Contest
A. Another Query on Array Problem B. Board Covering C. Cumulative Sums 题意 \(A_1=1,A_i=A_{i-1}+sod(A_ ...
- CodeForces 构造题专项解题报告
CodeForces 构造题专项解题报告 \(\newcommand \m \mathbf\)\(\newcommand \oper \operatorname\) \(\text{By DaiRui ...
- [LeetCode&Python] Problem 108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. Fo ...
- [LeetCode&Python] Problem 905: Sort Array By Parity
Given an array A of non-negative integers, return an array consisting of all the even elements of A, ...
- 1748E Yet Another Array Counting Problem
1748E Yet Another Array Counting Problem 目录 1748E Yet Another Array Counting Problem 题目大意: 做法 code 题 ...
随机推荐
- VictoriaMetrics 中文教程(10)集群版介绍
VictoriaMetrics 中文教程系列文章: VictoriaMetrics 中文教程(01)简介 VictoriaMetrics 中文教程(02)安装 VictoriaMetrics 中文教程 ...
- Nuxt.js 应用中的 nitro:init 事件钩子详解
title: Nuxt.js 应用中的 nitro:init 事件钩子详解 date: 2024/11/3 updated: 2024/11/3 author: cmdragon excerpt: n ...
- 5.3 Linux Vim三种工作模式
通过前面的学习我们知道,Linux 系统中所有的内容都以文件的形式进行存储,当在命令行下更改文件内容时,常会用到文本编辑器. 我们首选的文本编辑器是 Vim(至于为什么,可查看<Vi和Vim之间 ...
- Maven的顶级功能——依赖管理
依赖管理 依赖管理解决的问题 我们学完一个语言的语法之后,我们应该都能知道函数的引用或者类的创建等了.为了方便管理,我们就会把一些特定的功能实现写在一个代码文件中,我们只需要使用的时候导入就行了,这样 ...
- linux终端高级玩法详细介绍
专注于收集整理更多好玩技巧 更改终端命令行颜色 vi /etc/profile PS1='[\[\e[32m\]\u\[\e[0m\]\[\e[35m\]@\[\e[0m\]\[\e[33m\]\h\ ...
- 鸿蒙NEXT开发案例:简体繁体转换器
[引言] 简体繁体转换器是一个实用的小工具,它可以帮助用户轻松地在简体中文和繁体中文之间进行转换.对于需要频繁处理两岸三地文档的用户来说,这样的工具无疑是提高工作效率的好帮手.本案例将展示如何利用鸿蒙 ...
- The 2023 ICPC Asia Hong Kong Regional Programming Contest
The 2023 ICPC Asia Hong Kong Regional Programming Contest A. TreeScript 给你一个根,让你构造一棵树,每个节点被创造的时候必须知道 ...
- Echarts 提示组件
1.开启指示器 默认情况下,指示器是关闭状态,如果需要开启,直接配置tooltip字段即可 var option = { tooltip:{}, } 2.指示器的触发类型 触发类型的字段为trigge ...
- manim边做边学--多面体
在Manim中,对于多面体,有一系列封装好的类可以直接使用. 使用它们,可以方便快速的构建正多面体: Polyhedron:通过顶点和面的参数构建任意多面体 Tetrahedron:四面体 Octah ...
- SpringBoot+logback 日志打印脱敏,正常获取对象不受影响
添加依赖 注意:springboot版本2.7.0 <dependency> <groupId>org.slf4j</groupId> <artifactId ...