QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#568060 | #9313. Make Max | kouty | WA | 0ms | 6496kb | C++14 | 764b | 2024-09-16 15:06:19 | 2024-09-16 15:06:20 |
Judging History
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'