题意不复述。

用个bool数组记录一下,如果某一天,当前剩下的最大的出现了的话,就输出一段。

#include<cstdio>
using namespace std;
int n;
bool vis[100010];
int main()
{
//	freopen("a.in","r",stdin);
	scanf("%d",&n);
	int x;
	int now=n;
	for(int i=1;i<=n;++i)
	  {
	  	scanf("%d",&x);
	  	vis[x]=1;
	  	if(vis[now])
	  	  {
	  	  	printf("%d",now);
	  	  	--now;
	  	  	while(vis[now])
	  	  	  {
	  	  		printf(" %d",now);
	  	  		--now;
	  	  	  }
	  	  }
	  	puts("");
	  }
	  
	return 0;
}

相关文章:

  • 2021-09-04
  • 2021-10-10
  • 2021-10-03
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
猜你喜欢
  • 2021-11-03
  • 2021-05-20
  • 2022-01-15
  • 2021-10-12
  • 2021-06-23
  • 2021-06-08
相关资源
相似解决方案