QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#139104#149. Perubashkort#Compile Error//C++201.7kb2023-08-12 17:48:442024-07-04 01:39:04

Judging History

你现在查看的是测评时间为 2024-07-04 01:39:04 的历史记录

  • [2024-09-10 16:41:08]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:58ms
  • 内存:12728kb
  • [2024-07-04 01:39:04]
  • 评测
  • [2023-08-12 17:48:44]
  • 提交

answer

#include "peru.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr int MOD = 1e9 + 7;
constexpr ll infLL = 3e18;

struct Heap {
    priority_queue<ll, vector<ll>, greater<>> ins, del;
    void insert(ll x) { ins.push(x); }
    void erase(ll x) { del.push(x); }
    ll top() {
        while (!del.empty() && ins.top() == del.top()) {
            ins.pop(), del.pop();
        }
        return ins.empty() ? infLL : ins.top();
    }
};

constexpr int N = 2.5e6 + 7;

ll dp[N];
int stk[N], stkFront = 0, stkBack = 0;
//ll deq[N], deqFront = 0, deqBack = 0;

int solve(int n, int k, int a[]){
    int ans = 0;
//    Heap h;
    for (int i = 0; i < n; ++i) {
        if (stkFront < stkBack && stk[stkFront] <= i - k) {
//            h.erase(dp[stk[stkFront]] + a[stk[stkFront + 1]]);
            stkFront += 1;
//            deqFront = min(deqFront + 1, deqBack);
        }
        while (stkBack > stkFront && a[stk[stkBack - 1]] <= a[i]) {
            if (stkBack - 2 >= stkFront) {
//                h.erase(dp[stk[stkBack - 2]] + a[stk[stkBack - 1]]);
            }
            stkBack -= 1;
        }
        if (stkFront < stkBack) {
//            h.insert(dp[stk[stkBack - 1]] + a[i]);
        }
        ll mn = 3e18;
        for (int c = 0; c < min(2000, stkBack - stkFront - 1); ++c) {
            mn = min(mn, a[stk[stkBack - c - 1]] + dp[stk[stkBack - c - 2]]);
        }
        stk[stkBack++] = i;
        int j = stk[stkFront];
        dp[i] = min(/*h.top()*/mn, a[j] + (i - k >= 0 ? dp[i - k] : 0));
        ans = (23LL * ans + dp[i]) % MOD;
//        cout << dp[i] << " ";
    }
//    cout << endl;
    return ans;
}

Details

implementer.cpp: In function ‘int main()’:
implementer.cpp:34:13: error: ‘fout’ was not declared in this scope; did you mean ‘out’?
   34 |     fprintf(fout, "%d\n", sol);
      |             ^~~~
      |             out
implementer.cpp: In function ‘char nextch()’:
implementer.cpp:15:31: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     if (pos == BUF_SIZE) fread(buf, BUF_SIZE, 1, fin), pos = 0;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~