제출 #92648

#제출 시각아이디문제언어결과실행 시간메모리
92648GioChkhaidzeMoney (IZhO17_money)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h>
using namespace std;
int n,a[1000006],f[1000006],fix[1000006],Ans;
void go(int x,int idx)
{
	int ko=0;
	Ans++;
	
	for (int i=idx+1; i<=n; i++)
	{
		if (fix[a[i]] || a[i]<x || (ko && x+1<a[i])) break;
		
		fix[a[i]]=1;

		if (x+1<a[i]) ko=1;
		
		x=a[i];
	}
}

main ()
{
	scanf("%d",&n);
	
	for (int i=1; i<=n; i++)
	{
		scanf("%d",&a[i]);
		f[a[i]]=i;
	}
		
	for (int i=1; i<=n; i++)
		if (!fix[i]) go(i,f[i]);
		
	cout<<Ans<<endl;
}

컴파일 시 표준 에러 (stderr) 메시지

money.cpp:21:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main ()
       ^
money.cpp: In function 'int main()':
money.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
money.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...