結果

問題 No.1438 Broken Drawers
ユーザー kotatsugame
提出日時 2021-03-26 21:23:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 308 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 63,732 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-28 21:22:24
合計ジャッジ時間 2,963 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
int A[2<<17],inv[2<<17];
bool usd[2<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		A[i]--;
		inv[A[i]]=i;
	}
	int cnt=0;
	for(int i=0;i<N;i++)
	{
		int id=inv[i];
		if(id+1<N&&usd[id+1])continue;
		usd[id]=true;
		cnt++;
	}
	cout<<cnt<<endl;
}
0