2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L
来源:互联网 发布:电脑抓阄软件 编辑:程序博客网 时间:2024/05/22 01:52
The Heaviest Non-decreasing Subsequence Problem(最长不下降子序列变形)
Let S be a sequence of integers s1, s2, ..., sn Each integer is is associated with a weight by the following rules:
(1) If is is negative, then its weight is 0.
(2) If is is greater than or equal to 10000, then its weight is 5. Furthermore, the real integer value of si is si−10000 . For example, if si is 10101, then is is reset to 101 and its weight is 5.
(3) Otherwise, its weight is 1.
A non-decreasing subsequence of S is a subsequence si1, si2, ..., sik, with i1<i2 ... <ik, such that, for all 1≤j<k, we have sij<sij+1.
A heaviest non-decreasing subsequence of S 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:
80 75 73 93 73 73 10101 97 −1 −1 114 −1 10113 118
The heaviest non-decreasing subsequence of the sequence is <73,73,73,101,113,118> with the total weight being 1+1+1+5+5+1=14. Therefore, your program should output 14 in this example.
We guarantee that the length of the sequence does not exceed 2∗105
Input Format
A list of integers separated by blanks:s1, s2,...,sn
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
#include<cstdio>#include<algorithm>using namespace std;const int maxn = 1e6+5;//范围有毒,不要信题目的保证。尽量开大一点,反正不要钱。int a[maxn], d[maxn];int main(){int x,n=0,len=1;while (~scanf("%d", &x))//存序列{if (x < 0) continue;else if (x < 10000){a[n++] = x;}else{for (int j = 0; j < 5; j++){a[n++] = x - 10000;}}}d[1] = a[0];for (int i = 1; i < n; i++)//数组d保存长度为其下标的子序列的最小值{if (d[len] <= a[i]){len++;d[len] = a[i];}else{int j = upper_bound(d + 1, d + 1 + len, a[i])-d;//找到第一个大于a[i]的d[j]d[j] = a[i];}}printf("%d\n", len);//权值都为1,权值之和等于长度return 0;}转载地址:http://blog.csdn.net/lzc504603913/article/details/78078245
- 计蒜客 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L题
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L. The Heaviest Non-decreasing Subsequence Problem (LIS)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛-L. The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L题 非递减权值最大
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L. The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:L. The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L. The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L.The Heaviest Non-decreasing Subsequence Problem
- ACM 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B.Train Seats Reservation(模拟)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 F. Overlapping Rectangles(扫描线)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛: F. Overlapping Rectangles(线段树)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 F. Overlapping Rectangles(面积并)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 A. Weather Patterns(阅读题)
- 批量将图像原地(不开辟新空间)顺时旋转90度保存以及灰度化
- 架构师日记——MongoDB简介和安装使用
- 002_LeetCode_2 Add Two Numbers 题解
- 大型机、小型机、x86架构以及ARM架构服务器的区别
- 插入排序法
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L
- 音视频及FFMpeg概念篇
- 每周项目 补完计划 第八周 R语言基础
- 关于Winscp 密码获取解密
- Java笔记之代码块、继承、final
- 1-前端之路的开始-一个简单的计算器
- archlinux 开机自动连接wifi
- JNI 之数据类型与属性和方法的访问
- springx详解