QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124964#149. PeruAFewSuns0 51ms53700kbC++142.3kb2023-07-15 20:54:272024-09-10 16:39:46

Judging History

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

  • [2024-09-10 16:39:46]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:51ms
  • 内存:53700kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-15 20:54:31]
  • 评测
  • 测评结果:0
  • 用时:56ms
  • 内存:53396kb
  • [2023-07-15 20:54:27]
  • 提交

answer

#include "peru.h"
#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 1e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
#define mod 1000000007
ll f[2500025],q[2500025],l=1,r=0;
struct node{
	ll q[2500025],l=1,r=0,mid=1,pre[2500025],suf[2500025],val[2500025];
	il void remake(){
		if(l>r) return;
		fr(i,l-1,r+1) pre[i]=suf[i]=inf;
		mid=(l+r)>>1;
		pfr(i,mid,l) pre[i]=min(pre[i+1],val[i]);
		fr(i,mid+1,r) suf[i]=min(suf[i-1],val[i]);
	}
	il void dell(){
		l++;
		if(l>mid) remake();
	}
	il void delr(){
		r--;
		if(r<mid) remake();
	}
	il void addr(ll v){
		val[++r]=v;
		if(l==r) remake();
		else suf[r]=min(suf[r-1],v);
	}
	il void mdfl(ll v){
		val[l]=v;
		pre[l]=min(pre[l+1],val[l]);
	}
	il ll query(){
		return min(pre[l],suf[r]);
	}
}T;
int solve(int n,int k,int* a){
	pfr(i,n,1) a[i]=a[i-1];
	fr(i,1,n){
		f[i]=inf;
		while(l<=r&&q[l]<=(i-k)){
			l++;
			T.dell();
		}
		while(l<=r&&a[q[r]]<=a[i]){
			r--;
			T.delr();
		}
		q[++r]=i;
		q[l-1]=max(0ll,i-k);
		T.addr(f[q[r-1]]+a[i]);
		T.mdfl(f[q[l-1]]+a[q[l]]);
		f[i]=T.query();
	}
	ll ans=0,now=1;
	pfr(i,n,1){
		ans=(ans+now*f[i]%mod)%mod;
		now=now*23ll%mod;
	}
	return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 18
Accepted
time: 2ms
memory: 14072kb

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:

559335223

result:

ok single line: '559335223'

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 14064kb

input:

2000 100
1019222751 1012312953 1005125581 978875481 967275037 967176717 965763637 960999157 957233281 956958729 953471924 942217905 936256081 925906257 922808341 918616993 918132100 915435367 911342035 909313549 902957201 902119531 900836861 99996937 892982026 884892282 884816596 884102145 883049077...

output:

18827948

result:

wrong answer 1st lines differ - expected: '818524087', found: '18827948'

Subtask #2:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 7ms
memory: 19152kb

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:

93460569

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #34:

score: 0
Wrong Answer
time: 51ms
memory: 53700kb

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:

113623613

result:

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