Maximum Absurdity(dp)

【202503】Wan:开放且先进的大规模视频生成模型【1.3B、14B】【支持对无限长度视频进行稳定的Inference】【Wan中的主要计算开销来自注意力机制】 wan: Open and Advanced Large-Scale Video Generative ModelsWan:开放且先进的大规模视频生成模型Wan Team, Alibaba Group Wan 团队,Alibaba GroupThis report presents Wan, a comprehensive and open suite of video foundation models designed to push the boundaries of video generation 阅读详情

Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President of Berland, G.W. Boosch, to be signed.

This time mr. Boosch plans to sign 2k laws. He decided to choose exactly two non-intersecting segments of integers from 1 to n of length k and sign all laws, whose numbers fall into these segments. More formally, mr. Boosch is going to choose two integers a, b (1 ≤ a ≤ b ≤ n - k + 1, b - a ≥ k) and sign all laws with numbers lying in the segments [a; a + k - 1] and [b; b + k - 1] (borders are included).

As mr. Boosch chooses the laws to sign, he of course considers the public opinion. Allberland Public Opinion Study Centre (APOSC) conducted opinion polls among the citizens, processed the results into a report and gave it to the president. The report contains the absurdity value for each law, in the public opinion. As mr. Boosch is a real patriot, he is keen on signing the laws with the maximum total absurdity. Help him.

Input
The first line contains two integers n and k (2 ≤ n ≤ 2·105, 0 < 2k ≤ n) — the number of laws accepted by the parliament and the length of one segment in the law list, correspondingly. The next line contains n integers x1, x2, …, xn — the absurdity of each law (1 ≤ xi ≤ 109).

Output
Print two integers a, b — the beginning of segments that mr. Boosch should choose. That means that the president signs laws with numbers from segments [a; a + k - 1] and [b; b + k - 1]. If there are multiple solutions, print the one with the minimum number a. If there still are multiple solutions, print the one with the minimum b.

Sample test(s)
input
5 2
3 6 1 1 6
output
1 4
input
6 2
1 1 1 1 1 1
output
1 3
Note
In the first sample mr. Boosch signs laws with numbers from segments [1;2] and [4;5]. The total absurdity of the signed laws equals 3 + 6 + 1 + 6 = 16.

In the second sample mr. Boosch signs laws with numbers from segments [1;2] and [3;4]. The total absurdity of the signed laws equals 1 + 1 + 1 + 1 = 4.

给一个长度为n的序列,找两个不相交的长度为k的子串,使他们的和最大,输出两个子串的起始位置。

处理不好就超时了= = ,之前超时的忘了,第二次写一下就想到正解了。
首先预处理出已这个位置为起始位置长度为k的和,
对于每个i,i表示后面那个长度为k的子串,那么对于它来说,最大的子串和就是前i个位置中最大的那一个,就是第一个子串的位置。
问题转化成快速找前i个中最大的子串,然后发现这个在遍历i的时候就可以快速处理,
i每次改变1,那么前i个中最大的子串其实只需要用前i - 1个中最大子串和新出现的子串比较即可。
具体理解可以画一画图示意一下。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1005;
ll a[200005],dp[200005];
int main()
{
    #ifdef LOCAL
    freopen("C:\\Users\\巍巍\\Desktop\\in.txt","r",stdin);
    //freopen("C:\\Users\\巍巍\\Desktop\\out.txt","w",stdout);
    #endif // LOCAL
    ll n,k;
    scanf("%lld%lld",&n,&k);
    for(ll i = 1;i <= n;i++)
        scanf("%lld",&a[i]);
    ll ans = 0;
    for(ll i = 1;i <= k;i++)
        ans = ans + a[i];
    dp[1] = ans;
    for(ll i = 2;i <= n - k + 1;i++)
    {
        ans = ans + a[i + k - 1] - a[i - 1];
        dp[i] = ans;
    }
    ans = dp[1] + dp[k + 1];
    ll pos = 1,pos1,pos2;
    pos1 = 1;pos2 = k + 1;
    for(ll i = k + 2;i <= n - k + 1;i++)
    {
        if(dp[i - k] > dp[pos])pos = i - k;
        if(dp[i] + dp[pos] > ans)
        {
            ans = dp[i] + dp[pos];
            pos1 = pos;
            pos2 = i;
        }
    }
    printf("%lld %lld\n",pos1,pos2);
    return 0;
}
Pixel 5 Root, 安装Xposed框架, 解锁5G教程 Pixel 5 5G手机root 教程 前几天买的手机终于到货了,现在又开始折腾了,经过我的努力,现在已经拥有root权限了。 阅读详情

相关推荐

避坑指南:QT Creator报Unknown module(s) in QT: serialport的5种解决方法

本文详细解析了Qt Creator报'Unknown module(s) in QT: serialport'错误的5种解决方法,包括检查Qt版本兼容性、安装缺失组件、配置Kit环境等。针对Windows和Linux平台提供具体操作步骤,帮助开发者快速解决串口通信模块问题,提升开发效率。

weixin_29197051的博客 157

Maximum Absurdity(dp思想+前缀和)

Maximum Absurdity 原题目:Maximum Absurdity 题解 处理长度为 k 的区间和用前缀和 处理不相交的两个区间和用 dp 思想,以 i 为界线,用四个数组分别记录位置 i 之前的区间和最优解以及位置和 i 之后的区间和最优解以及位置,然后遍历 i 得出最优解,巧妙解决不相交问题。 code #include<iostream> using namespace std; int n, k; int num[200010], index1[200010], in

Mei_Tou_Nao_的博客 219

Yolov2 训练时anchor是如何使用的?build_target

0.简略描述 1.将真值检测框变换到特征图尺度上 2.计算以特征图每个网格中心为中心点时所有锚框与真值检测框的交并比 3.取与真值检测框交并比最大的锚框的id,及真值检测框中心所在cell的id,有此,可将真值检测框与预测结果对应起来 4.计算位置回归损失,置信度损失,分类损失 1,网络的输出 图1 yolov2 网络对于检测框位置大小的输出是: 对于1个batch网络的输出的shape为[batch_size, H*W*num_anchors, 5+num_classes], 其中: num_

机器人视觉感知 2817

Maximum Absurdity

题目描述 Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all the...

qq_17853613的博客 307

MAX31865模块温度测量

本文主要介绍MAX31865 测温注意事项,并写出读取温度的示例代码,模块详细参数可以查阅相关手册,

7457

【coze实战】基于Coze的公众号图文自动化生成工作流实战解析

【coze实战】基于Coze的公众号图文自动化生成工作流实战解析

大家好,我是码农老gou,一名专注于编程技术的程序员。在这个博客中,我将与大家分享我在工作和学习中的经验、见解以及一些实用的技术干货。 1万+

CodeForces - 332B. Maximum Absurdity(前缀和+dp)

B. Maximum Absurditytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputReforms continue entering Berland. For example, during yesterday sitting the B...

I_believe_CWJ的博客 523

强化学习-动态规划

动态规划(dynamic programming)是程序设计算法中非常重要的内容,能够高效解决一些经典问题,例如背包问题和最短路径规划。动态规划的基本思想是将待求解问题分解成若干个子问题,先求解子问题,然后从这些子问题的解得到目标问题的解。动态规划会保存已解决的子问题的答案,在求解目标问题的过程中,需要这些子问题答案时就可以直接利用,避免重复计算。本章介绍如何用动态规划的思想来求解在马尔可夫决策过程中的最优策略。

qq_45481856的博客 2113

B. Maximum Absurdity

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Reforms continue entering Berland. For example, during yesterday

无知的我 1776

Power domain 划分该如何下手

假如PD1比PD3更always on的话,我们只需要插入普通buffer即可,因为PD3 on,PD1也肯定是ON,PD1 off,PD3肯定时off,PD1能cover PD3的电源情况,因此使用普通buffer也可,但是处于省电角度,我们还是使用AO buffer;在我们做多power domain时,在切分power domain时,需要谨慎,稍有不慎,就会出现congestion以及timing问题,那问题来了,我们在切分power domain时有什么考究么,今天小编就和大家一起讨论讨论。

芯冰乐 207

5、AIX系统硬件管理与故障诊断全解析

本文全面解析了AIX系统的硬件管理与故障诊断方法,涵盖系统管理服务(SMS)的使用、设备兼容性配置、设备配置数据库结构、常用命令如cfgmgr、lsattr、smitty devices的操作详解,并深入介绍了错误日志管理机制,包括errdemon、errpt、errlogger等命令的应用。通过实际案例分析和流程图展示,帮助系统管理员掌握从问题怀疑到诊断执行再到日志清理的完整流程,同时提供注意事项与最佳实践,助力AIX系统的稳定运行与高效维护。

y2z3a4b5c的博客 62

codeforces B.Maximum Absurdity 解题报告

题目链接:http://codeforces.com/contest/332/problem/B 题意:在一个序列中,在所有长度为k的区间里找出两个不重叠的最大和,输出这两个最大和所对应的开头的位置a和b。 一开始没有想到用dp来做,于是有了以下的错误思路(读者可以忽略):声明一个结构体,包括head(保存起始点)、tail(保存结束点)还有sum(保存长度为k的区间的和)。计算出整...

weixin_30528371的博客 174

Qt 国产嵌入式操作系统实现文字转语音功能(ekho库)

Qt 国产嵌入式操作系统实现文字转语音功能(TTS)_tts驱动 转文字-优快云博客在继上篇文章之后,甲方粑粑不满意使用eSpeak发出的声音太难听了,这就不得不找个替代品,声音稍微好听了一些。使用ekho开源库。Ekho(余音)是一个免费、开源的中文语音合成软件。它目前支持粤语、普通话(国语)、诏安客语、藏语、雅言(中国古代通用语)和韩语(试验中),英文则通过Festival间接实现。Ekho支持Linux、Windows和Android平台。

希望能帮助大家,希望大家多多支持,你们的支持是我前进的动力。 2754

Maximum Absurdity DP + 数学

Maximum Absurdity Time Limit:2000MSMemory Limit:262144KB64bit IO Format:%I64d & %I64u SubmitStatus Appoint description: System Crawler (2013-07-28) Description ...

weixin_30550271的博客 114

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

[CodeForces 332B]Maximum Absurdity[DP]

题目链接:[CodeForces 332B]Maximum Absurdity[DP] 题意分析: 寻找两个不重叠的长度为k的子串,使得它们之和最大。 解题思路: 第一想法是,处理出从这个点开始,长度为k的区间的总和,即getv[i]代表区间[i, i + k - 1]的和,然后想着这个能怎么用? 然后发现可以处理出来之后,从getv[1]开始枚举,dp[i]代表从i开始,和最大的区间和

闲停 503

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

codeforces 332b Maximum Absurdity dp

题意: 有n个数,找两个段(每个段长度为k)不相交,求出这两个段的和的最大值。 输出两个段的起始下标。 思路: dp[i][j]:走到i,已经选了j个段的最大值。 转移:dp[i][j] = dp[i-k][j-1] + sum[i]-sum[i-k]; 输出方案的话,根据dp的值dfs回去(不dfs也是可以的),因为方案已经记录在dp的转移中。 code: #include #

553

深度学习工具包 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")

CF 332 B.Maximum Absurdity【DP】

Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws

Irish_Moonshine的博客 617

codeforces332B - Maximum Absurdity 线段数 or dp

题意:给你一个序列,找两个长度为 k 且没有重合区间的数使得其和最大 解题思路: 1)线段树 想了半天想不出只能先用线段树撸了一发,这题dp 第一名只要了 9分钟。 就是把起点为 i 长度为 k 的和预处理出来,再用线段树枚举去找。 解题代码: 1 // File Name: 332b.cpp 2 // Author: darkdream 3 // Creat...

weixin_30535843的博客 138

Codeforces Round #193 (Div. 2) B. Maximum Absurdity (DP、RMQ两种解法)

B. Maximum Absurdity time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Reforms continue entering Berland. For

To be what you what to be! 1366

Codeforces 332B Maximum Absurdity(DP+前缀和处理)

题目链接:http://codeforces.com/problemset/problem/332/B 题目大意:给你n个数和一个整数k,要求找到不相交的两个长度为k的区间,使得区间和最大,输出这两个区间的起点。解题思路:先计算前缀和,然后预处理出maxsum[i],maxsum[i]记录i~n最大的长度为k子段的和。然后再去枚举即可。 1 #include<cstdio...

weixin_30648587的博客 132

CodeForces 332B Maximum Absurdity

题目大意: 给出一个序列,让找出不互相覆盖的两个长度为k的段,问在两个段的权值和最大的情况下,按照左边段的左端点排序,右边段的左端点作为第二关键字排序,得到的第一个答案。 题目分析: dp:dp1[maxn],dp2[maxn]; dp1【i】表示前i项连续k段最大值,dp2【i】表示后n-i项连续k段最大值,然后做一次循环就好 #include #i

Ezereal的博客 590

codeforce 332B Maximum Absurdity

原题链接 题意 一个长为N的序列,选择其中2个长为K的不相交区间,使两个区间和最大 题解 CF标签上写的好好的DP,做着做着发现就是前缀和思想嘛,哪里有DP?哪里有DP? #include using namespace std; typedef long long LL; const int maxn=2e5; LL sum[maxn+5]; LL prem

zwsign的博客 455

codeforces 332B B. Maximum Absurdity(rmq)

题目链接:codeforces 332B题目大意:给出一个序列,让找出不互相覆盖的两个长度为k的段,问在两个段的权值和最大的情况下,按照左边段的左端点排序,右边段的左端点作为第二关键字排序,得到的第一个答案。题目分析: 很水的数据结构的题目,我们只需要先利用前缀和预处理出所有长度为k的段的总权值。然后利用rmq维护区间最大值和得到这个最大值取得的段的最左位置。 然后我们枚举第二段的位置,然后找到在采

llin-黎辰 2682

Codeforces 332B Maximum Absurdity(暴力)

题意:给你一个序列,让你在里面选择两个不想交的长度为k的字段,是的和最大。 我第一次做还是用的dp,感觉复杂度有点高啊,后来发现直接预处理就好了。 预处理需要三个数组,分别是sum[i],Max[i],Max_id[i]。 sum[i]表示以i开头的长度为k的子段和 Max[i]表示在i之后的和最大的长度为k的字段和 Max_id[i]和上面对应,就是那个最大子段和的其实位置。 这样处理好之后=,直

只玩三国的程序猿的专栏 688

CodeForces 332 B. Maximum Absurdity 动规 求和最大的两段连续子列

前面做过好几个最大连续子列的问题,这个题是找两个已知长度的子列,满足这两段的和最大这一条件。核心是动规以及树状数组。 先说一下树状数组:第一个是sum[i]=sum[i-1]+num[i];以及seq[i]=sum[i+k-1]-sum[i-1];seq[i]表示i到i+k-1的和。 动规:dp[i]=a表示在以第i到n-k+1为起点的长度为k的子列中以a为起点的最大。状态转移方程是  若se

anqier0468的专栏 881

codeforces B. Maximum Absurdity 线段树查找最大值的位置

B. Maximum Absurdity time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Reforms continue entering Berland. For

liyunlonghere 695
上一篇: Writing Code(DP)
下一篇: A and B and Interesting Substrings(dp)
Techay
博客等级 码龄11年 11粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值