2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L. The Heaviest Non-decreasing Subsequence Problem

【SAP-MDG】工作流任务配置实战:从基础配置到代理分配详解 本文详细解析了SAP MDG工作流任务配置的全流程,从基础配置到代理分配的关键操作。通过实战案例和最佳实践,帮助用户掌握Configure Workflow Tasks的核心技巧,包括环境检查、代理分配、SWDD事务码使用及常见问题排查,提升主数据管理效率。 阅读详情

Let SS be a sequence of integers s_{1}s​1​​, s_{2}s​2​​, ......, s_{n}s​n​​ Each integer is is associated with a weight by the following rules:

(1) If is is negative, then its weight is 00.

(2) If is is greater than or equal to 1000010000, then its weight is 55. Furthermore, the real integer value of s_{i}s​i​​ is s_{i}-10000s​i​​−10000 . For example, if s_{i}s​i​​ is 1010110101, then is is reset to 101101 and its weight is 55.

(3) Otherwise, its weight is 11.

A non-decreasing subsequence of SS is a subsequence s_{i1}s​i1​​, s_{i2}s​i2​​, ......, s_{ik}s​ik​​, with i_{1}<i_{2}\ ...\ <i_{k}i​1​​<i​2​​ ... <i​k​​, such that, for all 1 \leq j<k1≤j<k, we have s_{ij}<s_{ij+1}s​ij​​<s​ij+1​​.

A heaviest non-decreasing subsequence of SS is a non-decreasing subsequence with the maximum sum of weights.

Write a program that reads a sequence of integers, and outputs the weight of its

heaviest non-decreasing subsequence. For example, given the following sequence:

8080 7575 7373 9393 7373 7373 1010110101 9797 -1−1 -1−1 114114 -1−1 1011310113 118118

The heaviest non-decreasing subsequence of the sequence is <73, 73, 73, 101, 113, 118><73,73,73,101,113,118> with the total weight being 1+1+1+5+5+1 = 141+1+1+5+5+1=14. Therefore, your program should output 1414 in this example.

We guarantee that the length of the sequence does not exceed 2*10^{5}2∗10​5​​

Input Format

A list of integers separated by blanks:s_{1}s​1​​, s_{2}s​2​​,......,s_{n}s​n​​

Output Format

A positive integer that is the weight of the heaviest non-decreasing subsequence.

样例输入
80 75 73 93 73 73 10101 97 -1 -1 114 -1 10113 118
样例输出
14
题目来源

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛

分析:人生的第一个树状数组优化dp题目,尴尬的是队友会dp,我会树状数组,很遗憾,没做出来。

这里介绍两种思路。

思路见代码 :

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

int tree[300005];
struct Node {
	int a[300005];
	int val[300005];
}data;
int dp[300005];
void add(int x,int num)
{
    for(int i=x;i<=300005;i+=i&-i)
    	if(num>tree[i])
        	tree[i]=num;
}
int read(int x)
{
    int num=0;
    for(int i=x;i>0;i-=i&-i)
    	if(num<tree[i])
    		num=tree[i];
    return num;
}
int main()
{
    int n=1;
    while(~scanf("%d",&data.a[n]))
	{
		if(data.a[n]<0)	//负数可以不存 
			continue;
		else if(data.a[n]>=10000)
		{
			data.a[n]-=10000;	//大于10000的数,real值是原数减10000 
			data.val[n]=5;
		}
		else
			data.val[n]=1;
		n++;
	}
	dp[1]=data.val[1];
	add(data.a[1],dp[1]);
	int ans=-1;
	for(int i=2;i<n;i++)
	{//为什么说是树状数组优化dp,因为这里本来是又一层循环,用来查找在满足data.a[j]<=data.a[i]的情况下,
	//寻找最大的dp[j];	所以咱们以 data.a[i]为区间坐标,求区间最值,从0~data.a[i]中找到的最大的dp[j],
	//一定满足 data.a[j]<=data.a[i]
		int j=read(data.a[i]);
		dp[i]=max(dp[i],j+data.val[i]);
		add(data.a[i],dp[i]);
		ans=max(ans,dp[i]);
	}
	printf("%d\n",ans);
    return 0;
}

第二种:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

int a[1000005];
int dp[1000005];
int main()
{
    int n;
    n=1; 
    while(~scanf("%d",&a[n]))
    {//既然只有val==1,5的时候有用,而且求的是不下降的heavies序列。那么不妨将这些val=5的
	//拆分成5个val=1的,然后直接求解最大不下降子序列。 
    	if(a[n]<0)
    		continue;
    	else if(a[n]>=10000)
    	{
    		a[n]-=10000;
    		int tem=a[n];
    		n++;
    		for(int i=0;i<4;i++)
				a[n++]=tem;
		}
    	else
    		n++;
	}
    int len=1;
    memset(dp,0,sizeof(dp));
    dp[1]=a[1];
    for(int i=2;i<n;i++)
    {
        if(a[i]>=dp[len])
            dp[++len]=a[i];
        else
        {
            int add = lower_bound(dp+1,dp+len+1,a[i]) - dp;
            while(dp[add]<=a[i])
            	add++;
            dp[add] = a[i];
        }
    }
    if(n==1 && a[n]<0)//注意边界情况处理 
		printf("0\n");
	else
		printf("%d\n",len);
    
    return 0;
}



Dify工作流自动化:如何用Trae AI助手10倍提升你的开发效率(含避坑指南) 本文详细介绍了如何利用Trae AI助手自动化生成Dify工作流,实现开发效率的10倍提升。通过构建DSL示例库、精准需求描述和四步实战法,开发者可将重复的配置工作交给AI,快速生成可运行的工作流,并提供了关键的避坑指南。 阅读详情

相关推荐

ADS谐波平衡仿真自动优化报错?三步搞定HB控件设置(附常见错误排查)

本文针对ADS谐波平衡仿真在自动优化中常见的报错问题,提供了三步核心排查法。首先检查并禁用HB控件中可能导致冲突的小信号仿真模式,其次合理化仿真频率与扫描参数设置,最后审视优化变量与目标的定义。通过精准配置HB控件以适配自动优化流程,能有效解决大多数仿真失败问题,确保非线性电路设计顺利进行。

c2d3e4f的博客 788

ICPC2017网络赛(南宁)子序列最大权值(树状数组+dp)

Let SS be a sequence of integers s_{1}s ​1 ​​ , s_{2}s ​2 ​​ , ......, s_{n}s ​n ​​ Each integer is is associated with a weight by the following rules: (1) If is is negative, then its weight is 00. (2) If is is greater than or equal to 1000010000, then its

雪的期许 1201

AD9361 官方例程

文章目录一、官方资料1.1 介绍1.2 下载 和 使用1.3 相关资料二、步骤2.1 在Vivado中构建HDL2.2 在SDK中构建No- OS总结 一、官方资料 1.1 介绍 HDL参考设计介绍:AD9361 HDL Reference Designs 无操作系统介绍:AD9361 No-OS Software 1.2 下载 和 使用 HDL下载:Download HDL 在Vivado中构建HDL:Building HDL No-OS下载:Download No-OS 1.3 相关资料 AD

weixin_44630490的博客 3万+

计蒜客 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem

Let SSS be a sequence of integers s1s_{1}s​1​​, s2s_{2}s​2​​, ........., sns_{n}s​n​​ Each integer is is associated with a weight by the following rules: (1) If is is negative, then its weight

咸鱼有梦想 307

【ENVI初学】查看影像空间分辨率及重采样

例如,如果线段长度为900米,对应的像素数量为30个,那么影像的空间分辨率为30米。通过计算长度与像素数量的比值,即可得到影像的空间分辨率。,在弹出的对话框中,输入重采样后输出文件的xy分辨率大小。在测量结果窗口中,可以看到该线段的长度以及角度。在影像上点击并拖动鼠标,绘制一条直线段。工具,选择要重采样的影像后点击ok。,避免了插值过程中光谱信息的改变。:最近邻插值法通过选择原始影像中。在ENVI中打开影像后右键选择。指示了每个像素的地理跨度(聚合为一个新像素,通常通过。方法一:查看影像的元数据。

weixin_41619112的博客 5571

从零开始做题:big_zip

内容为:You_know_the_bed_feels_warmer_Sleeping_here_alone_You_know_I_dream_in_color_And_do_the_things_I_want_You_think_you_got_the_best_of_me_Think_you_had_the_last_laugh_Bet_you_think_that_everything_good_is_gone。查看压缩包内容,发现有五字节长度的文件,用crc碰撞攻击破解明文。

weixin_44626085的博客 1242

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L.The Heaviest Non-decreasing Subsequence Problem 权值最大的最长带权非递减子序列

题目链接:The Heaviest Non-decreasing Subsequence Problem 思路:因为是找非递减子序列,所以如果数b的权值是a,可以当成a个数b连续排列在数组中。然后找最长非递减子序列的长度即可,下列代码LNDS()函数也可以作为最长非递减子序列的模板使用,时间复杂度nlog2(n)。#include <iostream> #include <cstdio> #inc

ganzibang 1万+

微信小程序 “net::ERR_CONNECTION_REFUSED” 报错大揭秘与破解之道

在微信小程序开发与运行过程中,“net::ERR_CONNECTION_REFUSED” 报错是开发者常遇难题。该错误意味着小程序与服务器连接建立失败,会导致功能无法使用、数据加载异常等问题,严重影响用户体验和业务运转。本文系统剖析此错误,从网络环境不佳、服务器异常、小程序配置有误等常见触发场景入手,提供网络、服务器、配置、代码等多维度排查步骤,给出针对性解决策略,如修复网络、处理服务器故障、修正配置与代码错误,还提出开发与运维阶段的预防措施,助力开发者高效解决该报错问题。

邓邓子的博客 6134

计蒜客 Magical Girl Haze (2018 ICPC亚洲区域赛网络赛 南京 L)(迪杰斯特拉)

题目链接:https://nanti.jisuanke.com/t/31001 There are NN cities in the country, and MM directional roads from uu to v(1\le u, v\le n)v(1≤u,v≤n). Every road has a distance c_ici​. Haze is a Magical Girl t...

LP_Cong 631

T527 uart串口配置导致系统进不去

T527 s_uart串口配置导致系统进不去。

Linux驱动开发工程师,熟悉Linux/Android底层驱动、TP、显示、IIC、网络等通用外设调试适配,Linux上层应用开发。常用平台瑞芯微、全志、恩智浦等。 675

风控域——决策引擎系统设计

本文详细介绍了风控决策引擎系统的设计与应用。决策引擎系统是一种智能化工具,可自动化、数据驱动地辅助或替代人工决策,广泛应用于金融、医疗、营销、风控等领域。文章阐述了决策引擎的核心功能,包括自动化决策、动态规则管理、实时处理和模型集成,以及系统组成,涵盖数据输入层、规则引擎和模型服务层。此外,还探讨了决策引擎的典型应用场景、技术架构、组件设计,以及风控决策引擎系统的技术方案、设计难点和重点。

庄小焱 3320

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L. The Heaviest Non-decreasing Subsequence Problem(最长非减子序列+思路)

The frequent subset problem is defined as follows. Suppose UU={1, 2,\ldots…,N} is the universe, and S_{1}S​1​​, S_{2}S​2​​,\ldots…,S_{M}S​M​​ are MM sets over UU. Given a positive constant \al

gyr 691

YOLOv11的网络结构概览(Backbone-Neck-Head):介绍骨干网络(Backbone)、特征融合层(Neck)和检测头(Head)的作用

YOLOv11架构解析:从特征提取到目标检测 YOLOv11继承了YOLO系列的经典三组件架构,包含Backbone、Neck和Head三部分。Backbone基于改进的CSPDarknet,通过Conv和C3模块进行多尺度特征提取;Neck采用FPN+PAN结构融合不同层次特征;Head负责检测任务输出。网络整体设计注重高效性和多尺度特征融合,采用C3模块优化信息流和梯度流,配合SPPCSPC增强特征表达能力。该架构在保持实时检测速度的同时,提升了目标检测精度,体现了YOLO系列"一次看全图&q

本博客聚焦 YOLOv11 全流程落地,涵盖架构优化、数据集处理、训练技巧与多场景部署,兼及国产数据库、Java 开发与 AI 模型应用,内容兼顾理论与工程实践,为开发者提供系统干货,助力高效提升技术能力。 1万+

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L. The Heaviest Non-decreasing Subsequence Problem (LIS)

原题: Let SS be a sequence of integers s_{1}s​1​​, s_{2}s​2​​, ......, s_{n}s​n​​Each integer is is associated with a weight by the following rules: (1) If is is negative, then its weight is 0

Lllll_sh的博客 372

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L. The Heaviest Non-decreasing Subsequence Problem

Let SS be a sequence of integers s_{1}s​1​​, s_{2}s​2​​, ......, s_{n}s​n​​ Each integer is is associated with a weight by the following rules: (1) If is is negative, then its weight is 00. (2)

LP_Cong 1296

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L. The Heaviest Non-decreasing Subsequence Problem(最长不下降子序列变形)

Let SS be a sequence of integers s_{1}s ​1 ​​ , s_{2}s ​2 ​​ , ......, s_{n}s ​n ​​ Each integer is is associated with a weight by the following rules: (1) If is is negative, then its weight is 00. (2) If is is greater than or equal to 1000010000, then

HJY 803

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛-L. The Heaviest Non-decreasing Subsequence Problem

DP题,我用<挑战程序设计竞赛>这本书上的最长上升子序列模板(时间复杂度nlogn)的思想做的,具体看代码吧。 代码:#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int INF=0x3f3f3f3f; const int maxn=2*1e6+10; const int maxm

kaven 4417

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:L. The Heaviest Non-decreasing Subsequence Problem

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:L. The Heaviest Non-decreasing Subsequence Problem Let SS be a sequence of integers s_{1}s​1​​, s_{2}s​2​​, ......, s_{n}s​n​​ Each integer is is associated with a weight by the following rules: (1) If is is negative, then its

Mitsuha_的博客 442

L. The Heaviest Non-decreasing Subsequence Problem -最长不降子序列变形nlogn-2017 ACM-ICPC 亚洲区(南宁赛区)网络赛

L. The Heaviest Non-decreasing Subsequence Problem -最长不降子序列变形nlogn-2017 ACM-ICPC 亚洲区(南宁赛区)网络赛Let SSS be a sequence of integers s1s_{1}s​1​​,s2s_{2}s​2​​,.........,sns_{n}s​n​​ Each integer is is associated with a weight by the following rules1) If is is ne

ly59782的博客 519

2017 icpc 南宁赛区 L.The Heaviest Non-decreasing Subsequence Problem(LIS)

Let SS be a sequence of integers s_{1}s ​1 ​​ , s_{2}s ​2 ​​ , ......, s_{n}s ​n ​​ Each integer is is associated with a weight by the following rules: (1) If is is negative, then its weight is 00. (2) If is is greater than or equal to 1000010000, then

风的记忆 481

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:The Heaviest Non-decreasing Subsequence Problem

线段树区间查询加单点更新

温姑娘的博客 418

The Heaviest Non-decreasing Subsequence Problem 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 常见问题

本来是个裸的线段树的题 但是把负数删掉,权重为5 的点,赋值5遍放到队列里 这样问题就转化成了求最长上升(非下降)子序列 #include #include #include #include #include #include #include #include #include #include #include #include #include #inclu

床前明月光 499

扩展欧几里德算法模版题(求逆元+分析+题目)HDU1576 A/B

首先给大家普及一下什么是扩展欧几里德算法,它是由欧几里德算法演变的,即我们常说的辗转相除法。 代码如下: int gcd(int a,int b){     return b?gcd(b,a%b):a; } 那么对于不完全为0的非负整数,a,b,gcd(a,b)表示a,b的最大公约数,必然存在整数对x,y使得  gcd(a,b)=ax+by  代码如下:

Singular__point的博客 3629

hdu 6206 Apple(Java大数)

Apple Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 806    Accepted Submission(s): 267 Problem Description Apple is Taotao's favo

Singular__point的博客 1050

hdu 2067 卡特兰数打表(求解多边形,圆形等分割问题,括号匹配)(一直在更新。。。)

百度百科:https://baike.baidu.com/item/%E5%8D%A1%E7%89%B9%E5%85%B0%E6%95%B0/6125746?fr=aladdin 卡特兰数又称卡塔兰数,英文名Catalan number,是组合数学中一个常出现在各种计数问题中出现的数列。 其前几项为 : 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 167

Singular__point的博客 894

Gym 100960B B. Forcefield

2015-2016 Petrozavodsk Winter Training Camp, Nizhny Novgorod SU Contest B. Forcefield time limit per test 1 second memory limit per test 256 mebibytes input standard input

Singular__point的博客 706
上一篇: poj 1269 Intersecting Lines(判断两条直线三种状态)
下一篇: poj 2653 Pick-up sticks
Singular__point
博客等级 码龄10年 38粉丝 160原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值