题意:给你一个序列,问你最少移动多少个数使得数列不递减。

解题思路:其实就是要找到这个数列的最长不递减子序列。

解题代码:

 1 // File Name: 269b.cpp
 2 // Author: darkdream
 3 // Created Time: 2015年03月09日 星期一 18时44分02秒
 4
 5 #include<vector>
 6 #include<list>
 7 #include<map>
 8 #include<set>
 9 #include<deque>
10 #include<stack>
11 #include<bitset>
12 #include<algorithm>
13 #include<functional>
14 #include<numeric>
15 #include<utility>
16 #include<sstream>
17 #include<iostream>
18 #include<iomanip>
19 #include<cstdio>
20 #include<cmath>
21 #include<cstdlib>
22 #include<cstring>
23 #include<ctime>
24 #define LL long long
25
26 using namespace std;
27 int a[10000];
28 int ans[10000];
29 int n , m;
30 int Find(int l , int r,  int x )
31 {
32     while(l <= r )
33     {
34       int m = (l + r)/2;
35       if(ans[m] <= x )
36       {
37          l = m + 1;
38       }else {
39          r = m - 1;
40       }
41     }
42     return l;
43 }
44 int solve()
45 {
46     int t = 1;
47     ans[1] = a[1];
48    for(int i = 2;i <= n;i ++)
49    {
50        if(a[i] >= ans[t])
51        {
52           t ++ ;
53           ans[t] = a[i];
54        }else{
55           //printf("%d %d\n",i,Find(1,t,a[i]));
56           ans[Find(1,t,a[i])] = a[i];
57        }
58        /*for(int i = 1;i <= t;i ++)
59            printf("%d ",ans[i]);
60        printf("\n");*/
61    }
62    return n - t;
63 }
64 int main(){
65   scanf("%d %d",&n,&m);
66   double tmp ;
67   for(int i = 1;i <= n;i ++)
68   {
69     scanf("%d %lf",&a[i],&tmp);
70   }
71   printf("%d\n",solve());
72 return 0;
73 }

View Code

转载于:https://www.cnblogs.com/zyue/p/4324381.html

codeforces 269B Greenhouse Effect相关推荐

  1. [Codeforces Round #165 (Div. 2)]D. Greenhouse Effect

    地址:http://codeforces.com/contest/270/problem/D 这题看过别人代码,理解了好久 本来觉得这题和USACO里的三值的排序是一样的,但是USACO里通不过... ...

  2. 第三周 7.25 --- 7.31

    新的一周...>_< 7.25 hdu 5750  Dertouzos 定义 d 为 一个数的最大的除它本身的约数,给出 n,D,问小于 n 的数里有多少个数的d 为 D 比赛的时候 只想 ...

  3. Soil Ecology Letters被ESCI收录

    2021年5月5日,Soil Ecology Letters 被Emerging Source Citation Index(ESCI)数据库正式收录.这是创刊1年多之后,本刊入选的又一国际重要数据库 ...

  4. 【英语学习】【加州教材】【G6】【科学】Earth Science目录及术语表

    本文是英语学习笔记,所有版权归原教材作者所有. 加州六年级科学课本,名称为<Earth Science>,主要分为5个大Section,每个Section由两到三个Chapter构成,每个 ...

  5. 英语六级高频词汇速记 + 2019-6-2听力 Day06

    收藏 | 英语六级高频词汇1000个16天背完 endow vt. 捐赠:赋予 provision n. 供应:准备: patriot n. 爱国者 democratic a. 民主的 unconsc ...

  6. 环境资源与相关词汇中英文对照

    大气 ATMOSPHERE 大气组成 Atmospheric composition 空气质量 Air quality 大气化学 Atmospheric chemistry 大气成分 Atmosphe ...

  7. Kingofark的人工智能启示录

    K ][ N G of A R K ™'s The Revelation Of AI K ][ N G of A R K ™的人工智能启示录 What's It Mean to Be Human, A ...

  8. 【考研英语】词汇积累(详细全面,2023最新版)

    (一)To add additionally,furthermore,moreover,in addition(另外,此外), also,besides,again,even more(更多地,更加, ...

  9. 研究生英语期末复习(Unit1)

    interact: /ˌɪntərˈækt/ v./ to act together or towards others or with others 互相作用:互相影响; 互动. In Boston ...

最新文章

  1. Optional java 用法_Java8 Optional 的正确使用方式
  2. 之一:CABasicAnimation - 基本动画
  3. 数据可视化(matplotlib绘图)
  4. 英语口语练习软件测试简历,软件测试员英语简历范文
  5. 为什么没有看到webcontent_环卫工人工资低工作辛苦,为什么还有那么多人愿意做呢?...
  6. 挑战IPOD功能最强MP3——Zune二代评测
  7. hdu 3592 差分约束
  8. jquery easyui+spring mnv 样式引不进,需要加载静态资源
  9. linux系统,清理缓冲池内存
  10. w25qxx SPI读取数据出来为全FF
  11. 沁恒微USB蓝牙单片机CH573F初步熟悉
  12. 拳皇世界服务器维护,拳皇世界3月1日更新维护公告 多组服务器开启数据互通[图]...
  13. 因为一个MySQL权限问题引发的填坑之一(ERROR1045:Access Denied for user 'root'@'localhost' (using password:YES))
  14. 2021年全国Python程序员薪资曝光,网友:吹的不多.....
  15. Word中的mathtype如何按章节插入公式编号
  16. 升级至4K超高清12G-SDI接口时需要考虑的三件事
  17. 全栈之路-前端篇 | 第一讲.基础前置知识【浏览器内核与网络知识】学习笔记
  18. 点心发布新版安卓优化大师
  19. 绿通科技在创业板开启申购:超额募资约19亿元,收入依赖贴牌
  20. 监听Mac OS X的全局鼠标事件

热门文章

  1. 小辣椒2019_小辣椒红辣椒7X尊享版(6GB 64GB)参数大全,好便宜的联发科手机
  2. java命令查看环境变量 user.home file.encoding等参数值
  3. java hive 查询语句,使用java连接hive,并执行hive语句详解
  4. java action上传文件_java实现文件上传
  5. 89600 matlab,是德KEYSIGHT N9000B CXA 信号分析仪,多点触控,9 kHz 至 26.5 GHz
  6. java 设计模式_快速上手Java设计模式之简介
  7. c++ map初始化同时赋值_Golang学习笔记五--map
  8. docker 镜像加速
  9. awk使用shell中的变量
  10. CentOS6.7安装scala2.11.7