QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#127894 | #149. Peru | DerekFeng | Compile Error | / | / | C++23 | 1.1kb | 2023-07-20 11:12:04 | 2024-09-10 16:40:03 |
Judging History
你现在查看的是最新测评结果
- [2024-09-10 16:40:03]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-20 11:12:05]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-07-20 11:12:04]
- 提交
answer
#include<bits/stdc++.h>
//#include"peru.h"
using namespace std;
typedef long long ll;
const int N=2.5e6+4;
int dq[N],S=1,T;ll f[N];
struct DS{
ll v0[N],v1[N],m0[N],m1[N],vec[N];int s0,s1;
DS(){m0[0]=m1[0]=1e18;}
void rb(int x){
int sz=0;
for(int i=s0;i;i--)vec[++sz]=v0[i];
for(int i=1;i<=s1;i++)vec[++sz]=v1[i];
s0=sz+x>>1,s1=sz-s0;
for(int i=1;i<=s0;i++)v0[i]=vec[s0-i+1],m0[i]=min(m0[i-1],v0[i]);
for(int i=1;i<=s1;i++)v1[i]=vec[s0+i],m1[i]=min(m1[i-1],v1[i]);
}
void psb(ll x){v1[++s1]=x,m1[s1]=min(m1[s1-1],x);}
void ppf(){if(!s0)rb(1);s0--;}
void ppb(){if(!s1)rb(0);s1--;}
ll top(){return min(m0[s0],m1[s1]);}
}ds;
int solve(int n,int k,int *s){
for(int i=1;i<=n;i++){
int x=s[i-1];
while(S<=T&&dq[S]<i-k)S++,ds.ppf();
while(S<=T&&s[dq[T]-1]<=x)T--,ds.ppb();
if(S<=T)ds.ppb(),ds.psb(f[dq[T]]+x);dq[++T]=i;
f[i]=min(f[max(i-k,0)]+s[dq[S]-1],ds.top()),ds.psb(0);
}
const int M=1e9+7;ll sum=0;
for(int i=n,pw=1;i;i--,pw=23ll*pw%M)sum+=(ll)pw*f[i]%M;
return sum%M;
}
int ss[N];
int main(){
int n,k;cin>>n>>k;for(int i=0;i<n;i++)cin>>ss[i];
cout<<solve(n,k,ss);
}
詳細信息
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; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/bin/ld: /tmp/cc7BSNdF.o: in function `main': answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/cc4Pup3G.o:implementer.cpp:(.text.startup+0x0): first defined here collect2: error: ld returned 1 exit status