QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#139113#149. Perubashkort#0 75ms36928kbC++201.8kb2023-08-12 17:52:422024-09-10 16:41:22

Judging History

你现在查看的是最新测评结果

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

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]);
        }
        stk[stkBack++] = i;
        ll mn = 3e18;
        for (int c = 0; c < min(10, stkBack - stkFront - 1); ++c) {
            mn = min(mn, a[stk[stkBack - c - 1]] + dp[stk[stkBack - c - 2]]);
        }
        for (int c = stkBack - stkFront - 2, cnt = 0; c >= 0 && cnt < 10; --c, ++cnt) {
            mn = min(mn, a[stk[stkBack - c - 1]] + dp[stk[stkBack - c - 2]]);
        }
        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;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7900kb

input:

2000 170
1054018657 1037445664 1011691297 1009972317 1006506677 1002579733 999792775 999477541 975467893 970302369 968173111 957735623 953086083 938540451 932313113 930563895 924682633 917831575 913506401 908739591 905368525 899452913 894354220 890127447 885923007 583391543 880642788 878397752 87822...

output:

669606323

result:

wrong answer 1st lines differ - expected: '559335223', found: '669606323'

Subtask #2:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 13ms
memory: 13576kb

input:

400000 1000
1999989721 1999987224 1999984551 1999977673 1999977545 1999976801 1999975837 1999972607 1999956301 1999952801 1999942489 1999940593 1999940337 1999936353 1999936273 1999926073 1999925513 1999922980 1999918301 1999912501 1999909301 1999906125 1999902913 1999895622 1999893617 1999885490 19...

output:

787007064

result:

wrong answer 1st lines differ - expected: '677928817', found: '787007064'

Subtask #3:

score: 0
Wrong Answer

Test #34:

score: 0
Wrong Answer
time: 75ms
memory: 36928kb

input:

2500000 2000
1073315871 1073250349 1072791751 1072104046 1072071097 1071841833 1071809381 1071710686 1071580105 1071482003 1071383725 1071154701 1070499431 1070335288 1070334157 1069943617 1069681476 1069584279 1069581771 1069322519 1069189353 1069125955 1068832186 1068797487 1068662939 1068565681 1...

output:

961337257

result:

wrong answer 1st lines differ - expected: '12623259', found: '961337257'