AtCoder D - 高橋君と見えざる手 / An Invisible Hand 简单思维题
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 简单思维题的更多相关文章
- 高橋君とホテル / Tak and Hotels
高橋君とホテル / Tak and Hotels Time limit : 3sec / Stack limit : 256MB / Memory limit : 256MB Score : 700 ...
- 高橋君とカード / Tak and Cards
高橋君とカード / Tak and Cards Time limit : 2sec / Stack limit : 256MB / Memory limit : 256MB Score : 300 p ...
- AT987 高橋君
AT987 高橋君 给出 \(n,\ k\) ,求 \(\displaystyle\sum_{i=0}^kC_n^k\) , \(T\) 次询问 \(T\leq10^5,\ 0\leq k\leq n ...
- Atcoder Grand Contest 001E - BBQ Hard(组合意义转化,思维题)
Atcoder 题面传送门 & 洛谷题面传送门 Yet another 思维题-- 注意到此题 \(n\) 数据范围很大,但是 \(a_i,b_i\) 数据范围很小,这能给我们什么启发呢? 观 ...
- AtCoder Beginner Contest 044 C - 高橋君とカード / Tak and Cards
题目链接:http://abc044.contest.atcoder.jp/tasks/arc060_a Time limit : 2sec / Memory limit : 256MB Score ...
- 高橋君とカード / 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 ...
- 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 ...
- 【AT987】高橋君
题目 成爷爷一眼秒,\(tql!!!\) 多组询问,求 \[\sum_{i=0}^kC_{n}^i \] 发现\(k<=n\)啊,于是我们可以把一组询问抽象成一个区间\([k,n]\) 左指针的 ...
- 【spring】-- 手写一个最简单的IOC框架
1.什么是springIOC IOC就是把每一个bean(实体类)与bean(实体了)之间的关系交给第三方容器进行管理. 如果我们手写一个最最简单的IOC,最终效果是怎样呢? xml配置: <b ...
随机推荐
- application 长用到的API
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- html5--3.7 input元素(6)
html5--3.7 input元素(6) 学习要点 input元素及其属性 input元素 用来设置表单中的内容项,比如输入内容的文本框,按钮等 不仅可以布置在表单中,也可以在表单之外的元素使用 i ...
- Android工程的目录结构
1.最大限度的将不需要出现在Java代码中的文件和代码本身分离开来 2.使用XML标记语言定义UI和数据结构 3.对于工程中的文件存储在工程目录中的那个位置有着严格的规定,在编译过程中Android会 ...
- css绘制三角形
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- CodeForces768B:Code For 1 (分治)
Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On hi ...
- Spring cloud基础模块学习
1.微服务架构构成 单体架构(通过应用集群和数据库集群来提高性能,多余模块存在浪费) 垂直架构(新的功能模块通过新项目来实现,数据库之间存在交叉关联.存在数据冗余,和单体架构一样通过扩展集群结点,成本 ...
- 杂项:MIS
ylbtech-杂项:MIS 1.返回顶部 1. 管理信息系统(Management Information System,简称MIS)是一个以人为主导,利用计算机硬件.软件.网络通信设备以及其他办公 ...
- 【旧文章搬运】Windows中全局钩子DLL的加载过程
原文发表于百度空间,2011-03-24========================================================================== 看雪上别人 ...
- 2.1-2.2 Hive 中数据库(Table、Database)基本操作
官网文档:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL 一.create table 1.官方字段 # # C ...
- 3-1Java程序的执行流程
3-1Java程序的执行流程 用记事本写一个简单的程序 存到:E:\java路径下 class HelloImooc{ public static void main(String[] agrg ...