QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#577349#9313. Make MaxquxaimenkanhaiWA 28ms5876kbC++202.1kb2024-09-20 10:38:492024-09-20 10:38:50

Judging History

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

  • [2024-09-20 10:38:50]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:5876kb
  • [2024-09-20 10:38:49]
  • 提交

answer

#include<bits/stdc++.h> 
#define lson p<<1
#define rson p<<1|1
#define int	long long
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ANS cout<<ans<<"\n";
#define forn for(int i=1;i<=n;i++)
#define form for(int i=1;i<=m;i++)
#define forq for(int i=1;i<=q;i++)
#define fornj for(int j=1;j<=n;j++)
#define formj for(int j=1;j<=m;j++)
#define forqj for(int j=1;j<=q;j++)
#define fornn for(int i=n;i>=1;i--)
#define formm for(int i=m;i>=1;i--)
#define forqq for(int i=q;i>=1;i--)
using namespace std;
const int nnu=2e5+10;
const int mod=1e9+7;
const double eps = 1e-5;
int qpow(int a,int m){
	if(a==0)return 0;
	int s=1;
	while(m){
		if(m&1) s=(s*a)%mod;
		m>>=1;a=(a*a)%mod;
	}
	return s;
}
int prime[nnu],cntPrime=0;
bool meoPrime[nnu];
bool judgePrime(int x){
	if(x==1)return false ;
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return false;
	}
	return true;
}
void initPrime(){
	int maxn=1e5;
	for(int i=2;i<=maxn;i++){
		if(meoPrime[i]==0)prime[++cntPrime]=i;
		for(int j=1;j<=cntPrime&&prime[j]*i<=maxn;j++){
			meoPrime[prime[j]*i]=1;
			if(i%prime[j]==0)break;
		}
	} 
} 
void add(int &t,int a){
	t=(t%mod+a%mod+mod)%mod;
}
int dx[]={0,0,0,-1,1};
int dy[]={0,1,-1,0,0};
int tt=1,ttt=1;
int n,q,m,k;
int ans=0;
int arr[nnu],brr[nnu],f[nnu],g[nnu];

int C(int n,int m){
	return f[n]*g[n-m]%mod*g[m]%mod;
}
void initC(){
	f[0]=g[0]=1;
	int maxn=2e5;
	for(int i=1;i<=maxn;i++){
		f[i]=(f[i-1]*i)%mod;
		g[i]=(g[i-1]*qpow(i,mod-2))%mod;
	}
}
struct inf{
	int num,cnt;
};

void solve(){
	//wipe data
	ans=0;
	stack<inf> stk; 
	//solve
	cin>>n;
	forn {
		int x;cin>>x;
		if(i==1){
			stk.push({x,1});
			continue;
		}
		int cc=1;
		while(stk.size()&&stk.top().num<=x){
			inf tmp=stk.top();
			stk.pop();
			if(tmp.num<x){
				ans+=tmp.cnt;
			}
			cc+=tmp.cnt;
		}
		stk.push({x,cc});
	}
	while(stk.size()>=2){
		inf post=stk.top();
		stk.pop();
		inf pre=stk.top();
		stk.pop();
		ans+=post.cnt;
		stk.push({pre.num,pre.cnt+post.cnt});
	}
	ANS;
}
signed main(void)
{
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);

	cin>>ttt;
	for(tt=1;tt<=ttt;tt++)solve();return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5876kb

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: 28ms
memory: 5672kb

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:

2276620
2350054

result:

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