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 SSis
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−11011310113 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 亚洲区(南宁赛区)网络赛

最长上升子序列

由最长上升子序列可以想到思路,把权值为5的数分成五个权值为1的数,只需要把权值为5的数连写5个,这样就转化为求最长上升子序列的长度了。

先预处理,所有负数全部去掉,因为如果负数在序列前面,会使最长上升子序列的长度增加,然后把值大于等于10000的数减去10000,连写5次,求最长上升子列的长度即可。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 1e6+10;
int temp[MAXN],a[MAXN], c[MAXN], n; int bin(int size, int k)
{
int l = 1, r = size;
while (l <= r)
{
int mid = (l + r) / 2;
if (k>=c[mid]) //升序
l = mid + 1;
else
r = mid - 1;
}
return l;
}
int LIS()
{
int i, j, cnt = 0, k;
for (i = 1; i <= n; i++)
{
if (cnt == 0 || a[i]>=c[cnt]) //升序
c[++cnt] = a[i];
else
{
k = bin(cnt, a[i]);
c[k] = a[i];
}
}
return cnt;
} int main()
{
// freopen("in.txt","r",stdin);
int t=1,i;
while (scanf("%d", &temp[t++])!=EOF);
n=t--;
//预处理
for(i=1,t=1;i<=n;i++)
{
if(temp[i]>=10000)
{
a[t++]=temp[i]-10000;
a[t++]=temp[i]-10000;
a[t++]=temp[i]-10000;
a[t++]=temp[i]-10000;
a[t++]=temp[i]-10000;
}else if(temp[i]>=0)
a[t++]=temp[i];
else
continue;
}
n=t--;
int tem = LIS();
cout<<tem<<endl;
return 0;
}

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem的更多相关文章

  1. 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M. Frequent Subsets Problem【状态压缩】

    2017 ACM-ICPC 亚洲区(南宁赛区)网络赛  M. Frequent Subsets Problem 题意:给定N和α还有M个U={1,2,3,...N}的子集,求子集X个数,X满足:X是U ...

  2. HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛)

    HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛) Panda Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: ...

  3. 2017ICPC南宁赛区网络赛 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 i ...

  4. 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)

    摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...

  5. ICPC 2018 徐州赛区网络赛

    ACM-ICPC 2018 徐州赛区网络赛  去年博客记录过这场比赛经历:该死的水题  一年过去了,不被水题卡了,但难题也没多做几道.水平微微有点长进.     D. Easy Math 题意:   ...

  6. Skiing 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛H题(拓扑序求有向图最长路)

    参考博客(感谢博主):http://blog.csdn.net/yo_bc/article/details/77917288 题意: 给定一个有向无环图,求该图的最长路. 思路: 由于是有向无环图,所 ...

  7. [刷题]ACM/ICPC 2016北京赛站网络赛 第1题 第3题

    第一次玩ACM...有点小紧张小兴奋.这题目好难啊,只是网赛就这么难...只把最简单的两题做出来了. 题目1: 代码: //#define _ACM_ #include<iostream> ...

  8. 2016 ACM/ICPC亚洲区大连站-重现赛 解题报告

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5979 按AC顺序: I - Convex Time limit    1000 ms Memory li ...

  9. 2014ACM/ICPC亚洲区鞍山赛区现场赛1009Osu!

    鞍山的签到题,求两点之间的距离除以时间的最大值.直接暴力过的. A - Osu! Time Limit:1000MS     Memory Limit:262144KB     64bit IO Fo ...

  10. 2017ICPC南宁赛区网络赛 Minimum Distance in a Star Graph (bfs)

    In this problem, we will define a graph called star graph, and the question is to find the minimum d ...

随机推荐

  1. MT6753/MT6755 呼吸灯功能添加

    利用mtk pmic自带的呼吸灯模式: 主要修改代码: kernel-3.10/drivers/misc/mediatek/leds/mt6755/leds.c   int mt_brightness ...

  2. java中文乱码问题的处理方式

    URL访问java时. 注意: URL: 编码二次 URLEncoder.encode(URLEncoder.encode(searchKey, "utf-8"),"ut ...

  3. Avro kafka(Producer-Consumer)

    https://blog.csdn.net/mlljava1111/article/details/51376990

  4. 二级域名相同的情况下子页面调用父页面的js方法

    这两天项目遇到这种需求.项目是一个平台级系统,其中嵌入了多款应用.在平台上可以使用这些应用操作业务. 现在产品提出了个需求:即在A应用中需要调用js方法来打开B应用. 处理方法是:平台js中给出个打开 ...

  5. Android 原生开发、H5、React-Native使用利弊和场景技术分享

    http://m.blog.csdn.net/article/details?id=51778086 发表于2016/6/28 18:52:46  1176人阅读      最近工作中接触到React ...

  6. Errors running builder 'JavaScript Validator' on

    eclipse编译提示Errors running builder 'JavaScript Validator' on 解决方法见下图 去掉 'JavaScript Validator' 即可

  7. 【Unix编程】进程间通信(IPC)

    进程间通信(IPC,InterProcess Communication)是指在不同进程之间传播或交换信息.IPC的方式通常有管道(包括无名管道和命名管道).消息队列.信号量.共享存储.Socket. ...

  8. Nginx入门详解文档

    1 文章内容 掌握nginx+tomcat反向代理的使用方法. 掌握nginx作为负载均衡器的使用方法. 掌握nginx实现web缓存方法. 2 nginx介绍 2.1 什么是nginx Nginx是 ...

  9. Error:(2, 0) No service of type Factory<LoggingManagerInternal> available in ProjectScopeServices. <

    compile报下面的错误Error:(2, 0) No service of type Factory available in ProjectScopeServices. 点击open file ...

  10. Matlab7.1——启动时只显示Logo

    1. 现象 Matlab7.1在启动时只显示Matlab的Logo: 2. 解决方法 听我的吧,这个是官方办法,我也亲自试过了1结束matlab进程:2在C:\user\APPDATA\Roaming ...