[ AGC007 D ] Shik and Game

Posted Protein_lzl 的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[ AGC007 D ] Shik and Game相关的知识,希望对你有一定的参考价值。

题目

Atcoder

思路

007D01.png
007D02.png

代码

#include <iostream>
#include <algorithm>
#include <cstring>
#define int long long
using namespace std;
const int N = 200010;
int n, E, T, q[N], a[N], f[N];
signed main() {
    cin >> n >> E >> T;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int hh = 0, tt = -1, k = 2e9;
    q[++tt] = 0;
    for (int i = 1; i <= n; i++) {
        // 不满足条件就踢出队列, 顺便更新情况2
        while (hh <= tt && 2 * (a[i] - a[q[hh] + 1]) > T) 
            k = min(k, f[q[hh]] - 2 * a[q[hh] + 1]), hh++;
        f[i] = min(f[q[hh]] + T, k + 2 * a[i]), q[++tt] = i;
    }
    cout << f[n] + E << endl;
    return 0;
}

以上是关于[ AGC007 D ] Shik and Game的主要内容,如果未能解决你的问题,请参考以下文章

agc007D - Shik and Game(dp 单调性)

AtCoder Grand Contest 007 E:Shik and Travel

AGC007 - C Pushing Ball

agc045_d Lamps and Buttons

[AGE] Shik and Travel

AGC001 D - Arrays and Palindrome构造