結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー kotatsugamekotatsugame
提出日時 2020-03-09 06:56:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 296 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 65,632 KB
実行使用メモリ 7,808 KB
最終ジャッジ日時 2024-04-30 17:44:09
合計ジャッジ時間 1,432 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 26 ms
7,680 KB
testcase_16 AC 22 ms
7,552 KB
testcase_17 AC 23 ms
7,552 KB
testcase_18 AC 39 ms
7,808 KB
testcase_19 AC 26 ms
7,808 KB
testcase_20 AC 16 ms
7,552 KB
testcase_21 AC 10 ms
7,424 KB
testcase_22 AC 19 ms
7,552 KB
testcase_23 AC 13 ms
7,424 KB
testcase_24 AC 29 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N;
int cnt[1<<20];
int A[1<<17];
int ans;
main()
{
	cin>>N;
	int l=0,nc=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		while(cnt[A[i]])
		{
			cnt[A[l++]]--;
			nc--;
		}
		nc++;
		cnt[A[i]]++;
		ans=max(ans,nc);
	}
	cout<<ans<<endl;
}
0