QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#568060#9313. Make MaxkoutyWA 0ms6496kbC++14764b2024-09-16 15:06:192024-09-16 15:06:20

Judging History

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

  • [2024-09-18 15:56:24]
  • hack成功,自动添加数据
  • (/hack/836)
  • [2024-09-16 15:06:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:6496kb
  • [2024-09-16 15:06:19]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int t,n,a[200005],ans,cnt[200005],maxx,dp[200005];
int k[200005],k1;

int main (){
	cin>>t;
	while(t--){
		ans=0;
		cin>>n;
		memset(cnt,0,sizeof(cnt));
		memset(dp,0,sizeof(dp));
		memset(k,0,sizeof(k));
		for (int i=1;i<=n;i++) cin>>a[i];
		for(int i=n;i>=1;i--){
			for(int j=i-1;j>=1;j--){
				if(a[i]>a[j])cnt[i]++;
				else break;
			}
		}
		for(int i=1;i<=n;i++){
			if(cnt[i]==i-1)k[i]=0;
			else k[i]=k[i-cnt[i]-1]+1;
			cout<<k[i]<<endl;
		}
		maxx=0;
		for(int i=1;i<=n;i++){
			if(a[i]>maxx){
				maxx=a[i];dp[i]=dp[i-1]+i-1;continue;
			}
			else if(a[i]==maxx){
				dp[i]=dp[i-1];
			}
			else{
				dp[i]=dp[i-1]+cnt[i]+k[i];
			}
			
		}
		cout<<dp[n]<<endl;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

0
0
1
0
1
0
0
1
2
0
1
2
3
3
0
0
0
3

result:

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