Submission #73501509


Source Code Expand

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=2e5+5; 
int n,ans;
int a[maxn],dp[maxn];
map<int,int> mp;
signed main()
{
	cin >>n;
	for (int i=1;i<=n;i++) cin >> a[i];
	for (int i=1;i<=n;i++)
	{
		if (mp.count(a[i]-1)) dp[i]=dp[mp[a[i]-1]]+1;
		else dp[i]=1;
		mp[a[i]]=i;
	}
	for (int i=1;i<=n;i++) ans=max(ans,dp[i]);
	cout << ans << endl;
	return 0;
} 

Submission Info

Submission Time
Task D - Max Straight
User ChaoticZao
Language C++23 (GCC 15.2.0)
Score 400
Code Size 411 Byte
Status AC
Exec Time 213 ms
Memory 19220 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 26
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 3572 KiB
00_sample_01.txt AC 2 ms 3472 KiB
00_sample_02.txt AC 2 ms 3476 KiB
01_random_00.txt AC 2 ms 3472 KiB
01_random_01.txt AC 2 ms 3408 KiB
01_random_02.txt AC 2 ms 3476 KiB
01_random_03.txt AC 123 ms 18960 KiB
01_random_04.txt AC 138 ms 19040 KiB
01_random_05.txt AC 100 ms 12692 KiB
01_random_06.txt AC 42 ms 8180 KiB
01_random_07.txt AC 213 ms 19188 KiB
01_random_08.txt AC 36 ms 5100 KiB
01_random_09.txt AC 2 ms 3696 KiB
01_random_10.txt AC 86 ms 6684 KiB
01_random_11.txt AC 89 ms 6772 KiB
01_random_12.txt AC 10 ms 3928 KiB
01_random_13.txt AC 91 ms 6880 KiB
01_random_14.txt AC 4 ms 3620 KiB
01_random_15.txt AC 100 ms 7060 KiB
01_random_16.txt AC 50 ms 5472 KiB
01_random_17.txt AC 104 ms 19052 KiB
01_random_18.txt AC 102 ms 18932 KiB
01_random_19.txt AC 110 ms 19100 KiB
01_random_20.txt AC 73 ms 14432 KiB
01_random_21.txt AC 140 ms 19220 KiB
01_random_22.txt AC 12 ms 4880 KiB