蒟蒻求助,单调队列T了两个点:#2 #10

P1440 求m区间内的最小值

XLost @ 2019-08-26 14:28:07

#include <bits/stdc++.h>

struct Info {
    int time, var;
};

int n, m, num;
std::deque <Info> Q;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin >> n >> m;
    for (register int i = 1; i <= n; i++) {
        std::cin >> num;
        if (Q.empty()) {
            std::cout << 0 << std::endl;
        } else {
            if (Q.front().time + m < i) {
                Q.pop_front();
            }
            std::cout << Q.front().var << std::endl;
        }
        while (!Q.empty() && Q.back().var >= num) {
            Q.pop_back();
        }
        Info im = {i, num};
        Q.push_back(im);
    }
    return 0;
}

救救孩子……


by Soledad_S @ 2019-08-26 14:29:36

cout???


by XLost @ 2019-08-26 14:31:43

窝试试scanf


by Magallan_forever @ 2019-08-26 14:32:57

手写优先队列


by XLost @ 2019-08-26 14:34:53

WTF? scanf A了?!


by XLost @ 2019-08-26 14:35:51

好毒。。。


by 142857cs @ 2019-08-26 14:37:25

这题瓶颈本来就在读入。。。


by 南方小包 @ 2019-08-26 14:43:27

试试cin.tie(0)\ and\ cout.tie(0)


by Smile_Cindy @ 2019-08-26 14:46:39

@Lost_person

1.使用cin,cout请关同步

2.不要使用endl


by XLost @ 2019-08-26 14:49:39

@Alpha emmm

问题是我已经把同步关了awa


by Smile_Cindy @ 2019-08-26 14:50:53

@Lost_person

那就不要使用endl


| 下一页