A题:

链接:http://codeforces.com/contest/580/problem/A

dp,最长连续不上升子序列

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=;
int a[maxn],dp[maxn];
int main()
{
int n;
while(cin>>n)
{
for(int i=;i<n;i++)
scanf("%d",&a[i]);
memset(dp,,sizeof(dp));
dp[]=;
for(int i=;i<n;i++)
{
if(a[i-]<=a[i])
dp[i]=dp[i-]+;
else
dp[i]=;
}
int mx=;
for(int i=;i<n;i++)
if(dp[i]>mx)
mx=dp[i];
cout<<mx<<endl;
}
return ;
}

B题:

链接:http://codeforces.com/contest/580/problem/B

贪心,先按照m升序排序,然后找出符合条件且最大的

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=;
typedef struct
{
long long m,s;
}point;
point p[maxn];
bool cmp(point a,point b)
{
return a.m<b.m;
}
int main()
{
long long n,d;
while(cin>>n>>d)
{
for(int i=;i<n;i++)
cin>>p[i].m>>p[i].s;
sort(p,p+n,cmp);
long long ans=;
long long cnt=;
int j=;
for(int i=;i<n;i++)
{
cnt+=p[i].s;
while(p[i].m-p[j].m>=d)
{
cnt-=p[j].s;
j++;
}
ans=max(ans,cnt);
}
cout<<ans<<endl;
}
return ;
}

C、D、E赛场上没有搞出来,抽时间来补上

最新文章

  1. 理解 Keystone 核心概念 - 每天5分钟玩转 OpenStack(18)
  2. Spring中servletFileUpload完成上传文件以及文本的处理
  3. JSP导入EXCEL样式
  4. [LeetCode]题解(python):062 Unique path
  5. C#使用SQL存储过程完整流程
  6. js与C#之间相互调用的一些方法
  7. “Cache-control”常见的取值有private、no-cache、max-age、must-revalidate等
  8. 【转】Centos 设置IP地址的几种方式
  9. django 自定义过滤器(filter)处理较为复杂的变量的实例
  10. Mybatis整理_01
  11. [机器学习Lesson 2]代价函数之线性回归算法
  12. 【我们一起写框架】MVVM的WPF框架(五)—完结篇
  13. Android 音视频开发(七): 音视频录制流程总结
  14. 痞子衡嵌入式:飞思卡尔Kinetis系列MCU启动那些事(1)- KBOOT架构
  15. Python生产者producer和consumer消费者案例写法,含有多线程,包含队列queue、JoinableQueue队列的用法
  16. Mac影音多媒体工具软件推荐
  17. 通过DMS连接RDS需要添加的DMS白名单地址
  18. How to set up github to work with Visual Studio 2013
  19. 103. Binary Tree Zigzag Level Order Traversal (Tree, Queue; BFS)
  20. 设计师别浪费时间啦,快来试试这款Sketch标注插件吧

热门文章

  1. java设计模式案例详解:工厂模式
  2. JPA 系列教程3-单向多对一
  3. sqlserver 2008 查看表描述,和表结构
  4. 在CDockablePane中嵌入CFormView
  5. IDAPython: importing “site” failed
  6. [转]解决LinearLayout中控件不能居右对齐
  7. http协议--笔记
  8. CSS小例收藏
  9. Opencv 图像叠加 添加水印
  10. Kth order statistcs