QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#152913 | #149. Peru | AbdelmagedNour# | Compile Error | / | / | C++20 | 1.1kb | 2023-08-29 00:24:04 | 2024-07-04 01:52:07 |
Judging History
你现在查看的是测评时间为 2024-07-04 01:52:07 的历史记录
- [2024-07-04 01:52:07]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-29 00:24:04]
- 提交
answer
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
//#include "grader.cpp"
#include "peru.h"
typedef long long ll;
const int N=2500005,mod=(1e9)+7;
struct FastSet{
priority_queue<ll>pq1,pq2;
void push(ll x){pq1.push(-x);}
void del(ll x){pq2.push(-x);}
ll top(){
while(!pq1.empty()&&!pq2.empty()&&pq1.top()==pq2.top())pq1.pop(),pq2.pop();
return pq1.empty()?LLONG_MAX:-pq1.top();
}
}st;
ll dp[N];
int solve(int n, int k, int* v){
deque<int>dq;
v--;
for(int i=1;i<=n;i++){
while(!dq.empty()&&dq.front()<i-k){
if(dq.size()>1)st.del(dp[dq[0]]+v[dq[1]]);
dq.pop_front();
}
while(!dq.empty()&&v[dq.back()]<=v[i]){
if(dq.size()>1)st.del(dp[dq[dq.size()-2]]+v[dq.back()]);
dq.pop_back();
}
if(!dq.empty())st.push(dp[dq.back()]+v[i]);
dq.push_back(i);
dp[i]=st.top();
dp[i]=min(dp[i],dp[max(i-k,0)]+v[dq.front()]);
}
long long res=0;
for(int i=1;i<=n;i++)res=(res*23+dp[i])%mod;
return res;
}
詳細信息
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; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~