QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#127894#149. PeruDerekFengCompile Error//C++231.1kb2023-07-20 11:12:042023-07-20 11:12:05

Judging History

你现在查看的是测评时间为 2023-07-20 11:12:05 的历史记录

  • [2024-09-10 16:40:03]
  • 管理员手动重测本题所有提交记录
  • [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]
  • 评测
  • [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);
}

Details

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/cckXj7yS.o: in function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/ccnG7wXS.o:implementer.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status