QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#139120#149. Perubashkort#Compile Error//C++201.3kb2023-08-12 17:58:172024-07-04 01:39:16

Judging History

This is a historical verdict posted at 2024-07-04 01:39:16.

  • [2024-09-10 16:41:31]
  • 管理员手动重测本题所有提交记录
  • Verdict: 49
  • Time: 47ms
  • Memory: 15768kb
  • [2024-07-04 01:39:16]
  • Judged
  • [2023-08-12 17:58:17]
  • Submitted

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;

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;
        }
        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]);
        }
        stk[stkBack++] = i;
        dp[i] = min(h.top(), a[stk[stkFront]] + (i - k >= 0 ? dp[i - k] : 0));
        ans = (23LL * ans + dp[i]) % MOD;
    }
    return ans;
}

详细

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;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~