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 ...
随机推荐
- spring多个数据源配置
sys.properties中的内容 jdbc.driverClassName=oracle.jdbc.driver.OracleDriver DB.url=jdbc\:oracle\:thin\:@ ...
- UVA - 10635 最长公共子序列
input n,p,q 2<=n<=250 1<=p,q<=n*n 1 a1 a2 a3 ... ap 1<ai<n*n,ai!=aj 1 b1 b2 b3 ... ...
- div.2/Bellovin<最长上升子序列>
题意: 序列arr[i--n];输出以a[i]为结尾的最长上升子序列.1<=n<=100000; 思路: O(n*log(n)),求最长上升子序列. #include<cstdio& ...
- android平台菜单返回键监听
//声明 void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event); //实现 //按键控制(检测onKeyReleased有反 ...
- Codeforces 691B s-palindrome
水题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #includ ...
- Ubuntu 12.04和Windows 7双系统安装图解
http://wenku.baidu.com/link?url=PZlnNOhY0SjHDW-teFFnCMzPYJVjx7vj6yWY-o5HHFLuFqhLI4uFcQVu_y0_6i7vpSnz ...
- Android Studio ADB响应失败解决方法(2CTo.com)
当启动Android Studio时,如果弹出 adb not responding. you can wait more,or kill "adb.exe" process ma ...
- protobuf与json互相转换
Java http://code.google.com/p/protobuf-java-format/ maven <dependency> <groupId>com.goog ...
- linq to sql DAL
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data. ...
- Zabbix之配置文件详解
zabbix的配置文件一般有三种:zabbixserver的配置文件zabbix_server.confzabbixproxy的配置文件zabbix_proxy.confzabbix_agentd的配 ...