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赛场上没有搞出来,抽时间来补上

codeforces #321 DIV2的更多相关文章

  1. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  2. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  3. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  4. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  5. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  6. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

  7. Codeforces Round #321 div2

    好像前几场的题解忘记写了, Orz 状态太差, 平均出两题   都不好意思写了 , 连掉4场, 都要哭晕了. 很水的一场, 写完A B C就去睡了  D题其实不难, E题研究Ing(已用一种奇怪的姿势 ...

  8. Codeforces #263 div2 解题报告

    比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...

  9. codeforces #round363 div2.C-Vacations (DP)

    题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...

随机推荐

  1. st-Spanning Tree

    st-Spanning Tree time limit per test 4 seconds memory limit per test 256 megabytes input standard in ...

  2. UITableView使用中的一些刁专问题总结

    tableview中cell的系统分隔线问题(分隔线顶满或者缩短) //tableview代理方法,设置系统cell的分隔线 -(void)tableView:(UITableView *)table ...

  3. js数组总结

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  4. Android开发10.2:UI组件AutoCompleteTextView(自动完成文本框)

    概述 AutoCompleteTextVeiw(自动完成文本框)从 EditText派生而出  PS :EditText用法介绍           当用户输入一定字符后,自动完成自动完成文本框会显示 ...

  5. 8--UI 初步认识 简易计算器

    UI是App的根基:一个App应该是先有UI界面,然后在UI的基础上增加实用功能(2)UI相对简单易学:UI普遍是学习过程中最简单的一块,能快速拥有成就感和学习兴趣(3)UI至关重要:开发中的绝大部分 ...

  6. android平台菜单返回键监听

    //声明 void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event); //实现 //按键控制(检测onKeyReleased有反 ...

  7. javascript 总结学习一

    1 , javascript字符集:javascript采用的是Unicode字符集编码.为什么要采用这个编码呢?原因很简单,16位的Unicode编码可以表示地球人的任何书面语言.这是语言 国际化的 ...

  8. java 设计模式之单利模式以及代理模式(静态)

    1:单利模式: public class Singleton { private static Singleton uniqueInstance = null; private Singleton() ...

  9. linux下的vim使用笔记

    环境:window下可以使用gvim编辑软件 学习主要是在ubuntu15敲击命令学习的视频来自于智普教育vim使用视频1. sudo apt show vi 查看安装的vi版本,当然了我的ubunt ...

  10. context-param与init-param的区别与作用

    <context-param>的作用: web.xml的配置中<context-param>配置作用 1. 启动一个WEB项目的时候,容器(如:Tomcat)会去读它的配置文件 ...