http://arc063.contest.atcoder.jp/tasks/arc063_b

因为每次都是选取最大值,那么用dp[i]表示第i个数结尾能得到最大是多少。

其实就是用a[i]去减去左边最小的那个数字。

然后就是统计有多少个一样的最大值了。。

hack点

T是没用的,我被坑了,以为最多只能T / 2次,那么答案是min(T / 2, cnt_max)

但是不是。就算你T / 2只是1,那么,我也可以走不同的道路来取得max,所以要改变的cnt_max还是要改变。

和T无关。。

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int maxn = 1e6 + ;
int dp[maxn];
void work() {
int n, t;
scanf("%d%d", &n, &t);
if (n == ) while();
int mi = (1LL << ) - ;
int mx = -((1LL << ) - );
for (int i = ; i <= n; ++i) {
int x;
scanf("%d", &x);
dp[i] = max(, x - mi);
mi = min(mi, x);
mx = max(mx, dp[i]);
}
int tim = ;
for (int i = ; i <= n; ++i) {
tim += dp[i] == mx;
}
int ans = tim;
cout << ans << endl;
} int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
work();
return ;
}

AtCoder D - 高橋君と見えざる手 / An Invisible Hand 简单思维题的更多相关文章

  1. 高橋君とホテル / Tak and Hotels

    高橋君とホテル / Tak and Hotels Time limit : 3sec / Stack limit : 256MB / Memory limit : 256MB Score : 700  ...

  2. 高橋君とカード / Tak and Cards

    高橋君とカード / Tak and Cards Time limit : 2sec / Stack limit : 256MB / Memory limit : 256MB Score : 300 p ...

  3. AT987 高橋君

    AT987 高橋君 给出 \(n,\ k\) ,求 \(\displaystyle\sum_{i=0}^kC_n^k\) , \(T\) 次询问 \(T\leq10^5,\ 0\leq k\leq n ...

  4. Atcoder Grand Contest 001E - BBQ Hard(组合意义转化,思维题)

    Atcoder 题面传送门 & 洛谷题面传送门 Yet another 思维题-- 注意到此题 \(n\) 数据范围很大,但是 \(a_i,b_i\) 数据范围很小,这能给我们什么启发呢? 观 ...

  5. AtCoder Beginner Contest 044 C - 高橋君とカード / Tak and Cards

    题目链接:http://abc044.contest.atcoder.jp/tasks/arc060_a Time limit : 2sec / Memory limit : 256MB Score ...

  6. 高橋君とカード / Tak and Cards AtCoder - 2037 (DP)

    Problem Statement Tak has N cards. On the i-th (1≤i≤N) card is written an integer xi. He is selectin ...

  7. AtCoder Beginner Contest 044 A - 高橋君とホテルイージー / Tak and Hotels (ABC Edit)

    Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement There is a hotel with ...

  8. 【AT987】高橋君

    题目 成爷爷一眼秒,\(tql!!!\) 多组询问,求 \[\sum_{i=0}^kC_{n}^i \] 发现\(k<=n\)啊,于是我们可以把一组询问抽象成一个区间\([k,n]\) 左指针的 ...

  9. 【spring】-- 手写一个最简单的IOC框架

    1.什么是springIOC IOC就是把每一个bean(实体类)与bean(实体了)之间的关系交给第三方容器进行管理. 如果我们手写一个最最简单的IOC,最终效果是怎样呢? xml配置: <b ...

随机推荐

  1. 存储过程系列五:完整的存储过程备份使用函数REPLACE()substr()

    CREATE OR REPLACE PROCEDURE "YLQXSCXKESL_GGXKZ_TO_QB" (                                    ...

  2. deepin软件中文乱码

    如图所示,deepin软件,会有这种情况,中文全是乱码,口口口.这表示很讨厌,学长给出的解决办法,将系统换成英文语言,这样确实解决了乱码,但是还是有问题,比如在写中文注释,又变成这样了. 去deepi ...

  3. 【C/C++】获取当前系统时间

    #include<iostream> #include<Ctime> using namespace std; int main() { time_t t; time(& ...

  4. C# 使用WebClient时,在多网卡时,指定IP发送Web请求

    需要定义一个类,重写GetWebRequest,在方法内,指定IP地址 public class MyWebClient : WebClient { private IPAddress ipAddre ...

  5. 五、mysql中sql语句分类及常用操作

    1.sql语句分类: DQL语句 数据查询语言 select DML语句 数据操作语言 insert delete update DDL语句 数据定义语言 create drop alter TCL语 ...

  6. SQL 系统表

    http://www.cnblogs.com/asdcer/archive/2007/05/14/746377.aspx

  7. c++中IO输入输出流总结<一>

    1 io类图关系 1.1 简化形式 1.1.2补充 iostream: istream:从流中读取 ostream:写入到流 iosteram:读写流 fstream: ifstream:从文件读 o ...

  8. sqlserver 拷贝同步多个表数据到另一张表

    --/****** Script for SelectTopNRows command from SSMS ******/ Insert into [DMSBusiness].[dbo].[Busin ...

  9. 爬虫代码实现四:采用Hbase存储爬虫数据(1)

    3.Hbase表设计: 1.窄表:列少行多,表中的每一行尽可能保持唯一. 2.宽表:列多行少,通过时间戳版本来进行区分取值. 窄表:比如说,这个表,rowkey由userid+时间+bbsid假设bb ...

  10. HDU 2586 How far away ? (LCA,Tarjan, spfa)

    题意:给定N个节点一棵树,现在要求询问任意两点之间的简单路径的距离,其实也就是最短路径距离. 析:用LCA问题的Tarjan算法,利用并查集的优越性,产生把所有的点都储存下来,然后把所有的询问也储存下 ...