QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#116334#3300. Cactus CompetitionwfycswWA 2ms9640kbC++141.9kb2023-06-28 15:35:462023-06-28 15:35:49

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-28 15:35:49]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:9640kb
  • [2023-06-28 15:35:46]
  • 提交

answer

#include<bits/stdc++.h>
#define RI register int
#define err puts("asd")	
#define ll long long
#define ull unsigned long long 
#define mk make_pair
#define LL __int128
#define fl fflush(stdout)
#define eb emplace_back
//#pragma GCC optimize(2)
//#define int long long 
using namespace std;

inline ll read(){
	ll s=0;register char c=getchar();bool f=0;
	while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}	
	while(c>='0'&&c<='9') s=(s<<1)+(s<<3)+c-48,c=getchar();
	return f?-s:s;
}

const int N=2e5+5;

int a[N],b[N],n,d[N],m,cnt,tong[N];
int maxl[N],minl[N],h[N],L[N],R[N],c[N];
ll ans;
bool vis[N];

struct ST{
	int f[20][N];
	
	inline void	init(){
		for(RI i=1;i<=n;++i);	
	}
};

signed main(){ 
//	freopen("1.cpp","r",stdin);
//	freopen("1.out","w",stdout);
	n=read();m=read();
	RI l,r,mid,pos,x,y,z,u,v,D=-1e9,F=1e9;
	for(RI i=1;i<=n;++i) a[i]=read(),a[i]=-a[i],D=max(D,a[i]),F=min(F,a[i]);
	for(RI i=1;i<=m;++i) b[i]=read();
	minl[0]=1e9;
	maxl[1]=minl[1]=a[1];
	for(RI i=2;i<=n;++i) maxl[i]=max(maxl[i-1],a[i]),minl[i]=min(minl[i-1],a[i]);
	for(RI i=1;i<=m;++i){
		if(b[i]>=D) d[++cnt]=i,vis[i]=1,c[cnt]=1;
		else h[i]=upper_bound(maxl+1,maxl+n+1,b[i])-maxl-1;
	}
	x=0;
	for(RI i=d[1];i<=m;++i){
		if(vis[i]){
			++x;y=d[i];z=1e9;
			continue;
		}
		z=min(z,b[i]);
		if(z>=minl[h[i]]) ++c[x];
	}
//	bool ok;L[1]=1;
//	for(RI i=2;i<=cnt;++i){
//		L[i]=i;ok=1;
//		for(RI j=d[i-1]+1;j<d[i];++j)
//			if(b[j]<F){ok=0;break;} 
//		if(ok) L[i]=L[i-1];
//	}
	bool ok;
	R[cnt]=cnt;
	for(RI i=cnt-1;i>0;--i){
		R[i]=i;ok=1;
		for(RI j=d[i+1]-1;j>d[i];--j)
			if(b[j]<F){ok=0;break;}
		if(ok) R[i]=R[i+1],c[i]+=c[i+1];	
	}
	x=cnt+1;
	for(RI i=d[cnt];i>0;--i){
		if(vis[i]){
			--x;y=d[i];z=1e9;
			//cout<<"debug "<<c[x]<<endl;
			ans+=c[x];
			continue;
		}
		z=min(z,b[i]);
		if(z>=minl[h[i]]){
			ans+=c[x];
		}
	}
	cout<<ans<<endl;
	return 0; 
}





 

详细

Test #1:

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

input:

3 3
-1 0 1
-1 0 1

output:

1

result:

ok single line: '1'

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 9640kb

input:

3 3
-1 0 1
1 0 1

output:

3

result:

wrong answer 1st lines differ - expected: '5', found: '3'