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. [K/3Cloud] 如何代码中动态设置当前活动页签

    this.GetControl<TabControl>(key).SelectedIndex=目标Index Ps:如下方式隐藏页签: this.View.GetControl(" ...

  2. 餐巾(cogs 461)

    [问题描述] 一个餐厅在相继的N天里,第i天需要Ri块餐巾(i=l,2,…,N).餐厅可以从三种途径获得餐巾. (1)购买新的餐巾,每块需p分: (2)把用过的餐巾送到快洗部,洗一块需m天,费用需f分 ...

  3. NOIP2013提高组D2T3 华容道

    n<=30 * m<=30 的地图上,0表示墙壁,1表示可以放箱子的空地.q<=500次询问,每次问:当空地上唯一没有放箱子的空格子在(ex,ey)时,把位于(sx,sy)的箱子移动 ...

  4. [bzoj4827][Hnoi2017]礼物_FFT

    礼物 bzoj-4827 Hnoi-2017 题目大意:给定两个长度为$n$的手环,第一个手环上的$n$个权值为$x_i$,第二个为$y_i$.现在我可以同时将所有的$x_i$同时加上自然数$c$.我 ...

  5. Servlet实现点击计数器

    以下内容引用自http://wiki.jikexueyuan.com/project/servlet/hits-counter.html: 一.Web页面的点击计数器 很多时候,可能有兴趣知道网站的某 ...

  6. component and slot

    component and slot 使用: 1.component panel <article class="message"> <div class=&qu ...

  7. 【CV论文阅读】Detecting events and key actors in multi-person videos

    论文主要介绍一种多人协作的视频事件识别的方法,使用attention模型+RNN网络,最近粗浅地学习了RNN网络,它比较适合用于处理序列的存在上下文作用的数据. NCAA Basketball数据集 ...

  8. Telnet登入cisco router 1800

    Login to Router and change to privileged modec:\>telnet 192.168.6.1Trying 192.168.6.1...Connected ...

  9. SDUT--找朋友(BFS&amp;&amp;DFS)

    找朋友 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描写叙述 X,作为户外运动的忠实爱好者,总是不想呆在家里.如今,他想把死宅Y从家 ...

  10. 2016.3.16__CSS3_选择器_边框_背景_蒙版mask__第九天

    CSS3 假设您认为这篇文章还不错.能够去H5专题介绍中查看很多其它相关文章. 今日课程预览 1. CSS3 的选择器 1.1 子选择器 比如:设置div下一级的p标签的颜色属性 div>p { ...