codeforces #321 DIV2
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的更多相关文章
- Codeforces #180 div2 C Parity Game
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...
- Codeforces #541 (Div2) - E. String Multiplication(动态规划)
Problem Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...
- Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)
Problem Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)
Problem Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...
- 【Codeforces #312 div2 A】Lala Land and Apple Trees
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...
- Codeforces Round #321 div2
好像前几场的题解忘记写了, Orz 状态太差, 平均出两题 都不好意思写了 , 连掉4场, 都要哭晕了. 很水的一场, 写完A B C就去睡了 D题其实不难, E题研究Ing(已用一种奇怪的姿势 ...
- Codeforces #263 div2 解题报告
比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...
- codeforces #round363 div2.C-Vacations (DP)
题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...
随机推荐
- Sanatorium
Sanatorium time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Spring Boot 系列教程5-热部署-devtools模块
devtools模块 devtools模块,是为开发者服务的一个模块.主要的功能就是代码修改后一般在5秒之内就会自动重新加载至服务器,相当于restart成功. 原理 简单原理 在发现代码有更改之后, ...
- Gym 100917L Liesbeth and the String 规律&&胡搞
题目: Description standard input/outputStatements Little Liesbeth likes to play with strings. Initiall ...
- POJ3321/Apple tree/(DFS序+线段树)
题目链接 Apple Tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9692 Accepted: 3217 Descr ...
- 关于glibc中的res_init()函数
/* * Set up default settings. If the configuration file exist, the values * there will have precede ...
- android sql Cursor
Cursor 是每行的集合. 使用 moveToFirst() 定位第一行. 你必须知道每一列的名称.你必须知道每一列的数据类型.Cursor 是一个随机的数据源. 所有的数据都是通过下标取得. Cu ...
- int *p[4]与int (*q)[4]的区别
以上定义涉及两个运算符:“*”(间接引用).“[]”(下标),“[]”的优先级别大于“*”的优先级别. 首先看int *p[4],“[]”的优先级别高,所以它首先是个大小为4的数组,即p[4]:剩下的 ...
- Entity Framework 6新功能Logging/Store Procedure
摘要 在Entity Framework6中有两个新的功能,DB Loggin和Stored Procedure的映射 Entity Framework 6已经从Beta版本来到了RC1版本,我们可以 ...
- tomcat服务器设置用户名和密码
conf/tomcat-user.xml <user username="admin" password="1234" roles="manag ...
- DNS开源服务器BIND最小配置详解<转>
一,简介 相对于存储和大数据领域,CDN是一个相对小的领域,但行行出状元,BIND就是CDN领域的蝉联N届的状元郎.BIND是一款非常常用的DNS开源服务器,全球有90%的DNS用BIND实现.值得一 ...