QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#567674#9313. Make MaxkoutyWA 105ms4312kbC++14768b2024-09-16 13:26:332024-09-16 13:26:33

Judging History

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

  • [2024-09-18 15:56:24]
  • hack成功,自动添加数据
  • (/hack/836)
  • [2024-09-16 13:26:33]
  • 评测
  • 测评结果:WA
  • 用时:105ms
  • 内存:4312kb
  • [2024-09-16 13:26:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int t,n,a[200005],ans;
void solve(int l,int r){
	if (r-l+1<=2){
		if (a[l]!=a[r]) ans++;
		return ;
	}
	else if(r-l+1==3){
		if((a[l]==a[l+1])&&(a[l+1]==a[r]))return;
		else if((a[l]==a[r]&&a[l+1]<a[l])||(a[l]==a[l+1]&&a[r]<a[l])||(a[l+1]==a[r]&&a[l]<a[r]))ans++;
		else if(a[l]!=a[l+1]&&a[l+1]!=a[r]&&a[l]!=a[r])ans+=3;
		else ans+=2;
		return;
	}
	int maxx=0,p=0,cnt=0;
	for (int i=l;i<=r;i++){
		if (maxx<a[i]) maxx=a[i],p=i,cnt=1;
		else if(maxx==a[i])cnt++;
	}
	if (p>l) solve(l,p-1);
	if (p<r) solve(p+1,r);
	ans+=r-l;
	if (cnt>1) ans-=r-p;
}
int main (){
	cin>>t;
	while(t--){
		ans=0;
		cin>>n;
		for (int i=1;i<=n;i++) cin>>a[i];
		solve(1,n);
		cout<<ans<<endl;
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

1
0
3
3

result:

ok 4 number(s): "1 0 3 3"

Test #2:

score: -100
Wrong Answer
time: 105ms
memory: 4312kb

input:

2
198018
875421126 585870339 471894633 383529988 625397685 944061047 704695631 105113224 459022561 760848605 980735314 847376362 980571959 329939331 644635272 326439858 752879510 837384394 175179068 182094523 397239381 1199016 185143405 279638454 252374970 822030887 860312140 137248166 993229443 164...

output:

4091680
4136884

result:

wrong answer 1st numbers differ - expected: '4084978', found: '4091680'