結果

問題 No.1055 牛歩
ユーザー 👑 hitonanodehitonanode
提出日時 2020-05-17 16:35:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 1,000 ms
コード長 3,028 bytes
コンパイル時間 4,257 ms
コンパイル使用メモリ 218,708 KB
実行使用メモリ 9,940 KB
最終ジャッジ日時 2023-10-26 01:09:32
合計ジャッジ時間 10,165 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
8,760 KB
testcase_01 AC 45 ms
9,568 KB
testcase_02 AC 42 ms
4,916 KB
testcase_03 AC 43 ms
4,916 KB
testcase_04 AC 42 ms
4,916 KB
testcase_05 AC 43 ms
4,916 KB
testcase_06 AC 46 ms
4,900 KB
testcase_07 AC 31 ms
4,884 KB
testcase_08 AC 46 ms
4,900 KB
testcase_09 AC 37 ms
4,788 KB
testcase_10 AC 37 ms
4,788 KB
testcase_11 AC 37 ms
4,788 KB
testcase_12 AC 18 ms
5,708 KB
testcase_13 AC 17 ms
5,708 KB
testcase_14 AC 38 ms
4,716 KB
testcase_15 AC 37 ms
4,716 KB
testcase_16 AC 28 ms
4,776 KB
testcase_17 AC 33 ms
4,712 KB
testcase_18 AC 34 ms
4,792 KB
testcase_19 AC 33 ms
4,712 KB
testcase_20 AC 36 ms
5,020 KB
testcase_21 AC 44 ms
4,992 KB
testcase_22 AC 50 ms
4,760 KB
testcase_23 AC 49 ms
5,028 KB
testcase_24 AC 50 ms
5,008 KB
testcase_25 AC 49 ms
9,552 KB
testcase_26 AC 49 ms
9,148 KB
testcase_27 AC 52 ms
9,940 KB
testcase_28 AC 56 ms
8,612 KB
testcase_29 AC 55 ms
8,916 KB
testcase_30 AC 60 ms
9,940 KB
testcase_31 AC 9 ms
4,372 KB
testcase_32 AC 7 ms
4,372 KB
testcase_33 AC 10 ms
4,372 KB
testcase_34 AC 6 ms
4,372 KB
testcase_35 AC 9 ms
4,372 KB
testcase_36 AC 10 ms
4,372 KB
testcase_37 AC 6 ms
4,372 KB
testcase_38 AC 7 ms
4,372 KB
testcase_39 AC 2 ms
4,372 KB
testcase_40 AC 2 ms
4,372 KB
testcase_41 AC 2 ms
4,372 KB
testcase_42 AC 2 ms
4,372 KB
testcase_43 AC 2 ms
4,372 KB
testcase_44 AC 2 ms
4,372 KB
testcase_45 AC 2 ms
4,372 KB
testcase_46 AC 2 ms
4,372 KB
testcase_47 AC 2 ms
4,372 KB
testcase_48 AC 2 ms
4,372 KB
testcase_49 AC 2 ms
4,372 KB
testcase_50 AC 1 ms
4,372 KB
testcase_51 AC 2 ms
4,372 KB
testcase_52 AC 1 ms
4,372 KB
testcase_53 AC 2 ms
4,372 KB
testcase_54 AC 1 ms
4,372 KB
testcase_55 AC 2 ms
4,372 KB
testcase_56 AC 1 ms
4,372 KB
testcase_57 AC 2 ms
4,372 KB
testcase_58 AC 2 ms
4,372 KB
testcase_59 AC 2 ms
4,372 KB
testcase_60 AC 1 ms
4,372 KB
testcase_61 AC 2 ms
4,372 KB
testcase_62 AC 1 ms
4,372 KB
testcase_63 AC 2 ms
4,372 KB
testcase_64 AC 2 ms
4,372 KB
testcase_65 AC 2 ms
4,372 KB
testcase_66 AC 2 ms
4,372 KB
testcase_67 AC 2 ms
4,372 KB
testcase_68 AC 1 ms
4,372 KB
testcase_69 AC 2 ms
4,372 KB
testcase_70 AC 2 ms
4,372 KB
testcase_71 AC 2 ms
4,372 KB
testcase_72 AC 2 ms
4,372 KB
testcase_73 AC 2 ms
4,372 KB
testcase_74 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

void No()
{
    puts("NO");
    exit(0);
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    cin >> A;

    vector<vector<int>> TS(M);

    int Q;
    cin >> Q;
    REP(t, Q)
    {
        int b;
        cin >> b;
        TS[b - 1].emplace_back(t + 1);
    }
    vector<pint> hist_prev{{{0, 0}}};
    REP(i, A.size())
    {
        priority_queue<pint, vector<pint>, greater<pint>> pq;
        for (auto x : hist_prev) pq.push(x);
        for (auto t : TS[i]) pq.emplace(t, -1);
        using P = pair<int, pint>;
        vector<P> hist{{0, {A[i], A[i]}}};

        int prev_now = (i ? A[i - 1] : 0);
        while (pq.size())
        {
            auto [t, x] = pq.top();
            pq.pop();
            if (x == -1)
            {
                auto [l, r] = hist.back().second;
                l--, r++;
                while (l <= prev_now) l += 2;
                hist.emplace_back(t, pint(l, r));
            }
            else
            {
                prev_now = x;
                int &l = hist.back().second.first;
                while (l <= prev_now) l += 2;
            }
        }
        vector<pint> hist_next(hist.size());
        IREP(i, hist.size())
        {
            if (hist[i].second.first > hist[i].second.second or hist[i].second.first > N) No();
            if (i)
            {
                chmax(hist[i - 1].second.first, hist[i].second.first - 1);
                chmin(hist[i - 1].second.second, hist[i].second.second + 1);
            }
            hist_next[i] = make_pair(hist[i].first, hist[i].second.first);
        }
        hist_prev = hist_next;
    }
    puts("YES");
}
0