蒟蒻MLE*2求助大佬
查看原帖
蒟蒻MLE*2求助大佬
610557
shinzanmonoszm 妹妹楼主2022/9/29 23:07
#include <iostream>
#define re register
using namespace std;
const int sz = 2e6 + 1;
const int lgsz = __lg(sz) + 1;
int f[lgsz][sz];
int main() {
    ios::sync_with_stdio(false);
    re int n, m;
    cin >> n >> m;
    for (re int i = 1; i <= n; i++)
        cin >> f[0][i];
    for (re int i = 1; i <= __lg(n); i++)
        for (re int j = 1; j + (1 << i) - 1 <= n; j++)
            f[i][j] = min(f[i - 1][j], f[i - 1][j + (1 << i - 1)]);
    cout << "0\n";
    for (re int i = 2; i <= n; i++) {
        re int lg = __lg(i - max(i - m, 1));
        cout << min(f[lg][max(i - m, 1)], f[lg][i - (1 << lg)]) << "\n";
    }
    return 0;
}

2022/9/29 23:07
加载中...