Submission #35310567


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
int n;
int a[300005];
map<int,int> mp;
int ba;
int ans;
int main()
{
	cin>>n;
	for(int t=0;t<n;t++)
	{
		cin>>a[t];
		mp[a[t]]++;
	}
	sort(a,a+n);
	for(int t=1;;t++)
	{
		if(mp[t]==0)
		{
			if(ba>1)
			{
				ba-=2;
				ans++;
			}
			else if(n>=1&&t<a[n-1]&&ba==1)
			{
				mp[a[n-1]]--;n--;ba--;ans++;
			}
			else if(n>=2&&t<a[n-2])
			{
				mp[a[n-1]]--;mp[a[n-2]]--;n-=2;ans++;
			}
			else
				break;
		}
		else
		{
			ans++;
			ba+=mp[t]-1;
			mp[t]--;
		}
	}
	cout<<ans;
	return 0;
}

Submission Info

Submission Time
Task C - Manga
User daisybunny
Language C++ (GCC 9.2.1)
Score 0
Code Size 581 Byte
Status WA
Exec Time 359 ms
Memory 25780 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 28
WA × 1
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_one_00.txt, 01_one_01.txt, 01_one_02.txt, 02_srnd_00.txt, 02_srnd_01.txt, 02_srnd_02.txt, 02_srnd_03.txt, 02_srnd_04.txt, 02_srnd_05.txt, 02_srnd_06.txt, 03_rnd_00.txt, 03_rnd_01.txt, 03_rnd_02.txt, 03_rnd_03.txt, 04_max_00.txt, 04_max_01.txt, 04_max_02.txt, 05_same_00.txt, 05_same_01.txt, 05_same_02.txt, 05_same_03.txt, 05_same_04.txt, 05_same_05.txt, 06_concat_00.txt, 06_concat_01.txt, 06_concat_02.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 8 ms 3616 KiB
00_sample_01.txt AC 2 ms 3440 KiB
00_sample_02.txt AC 2 ms 3612 KiB
01_one_00.txt AC 2 ms 3516 KiB
01_one_01.txt AC 2 ms 3624 KiB
01_one_02.txt AC 3 ms 3536 KiB
02_srnd_00.txt AC 2 ms 3608 KiB
02_srnd_01.txt AC 2 ms 3612 KiB
02_srnd_02.txt AC 4 ms 3404 KiB
02_srnd_03.txt AC 2 ms 3536 KiB
02_srnd_04.txt AC 3 ms 3404 KiB
02_srnd_05.txt AC 3 ms 3448 KiB
02_srnd_06.txt AC 2 ms 3616 KiB
03_rnd_00.txt AC 356 ms 22588 KiB
03_rnd_01.txt WA 354 ms 22556 KiB
03_rnd_02.txt AC 359 ms 22668 KiB
03_rnd_03.txt AC 358 ms 22660 KiB
04_max_00.txt AC 233 ms 18856 KiB
04_max_01.txt AC 234 ms 18840 KiB
04_max_02.txt AC 358 ms 18744 KiB
05_same_00.txt AC 137 ms 11656 KiB
05_same_01.txt AC 134 ms 11756 KiB
05_same_02.txt AC 131 ms 11756 KiB
05_same_03.txt AC 134 ms 11660 KiB
05_same_04.txt AC 133 ms 11796 KiB
05_same_05.txt AC 135 ms 11660 KiB
06_concat_00.txt AC 222 ms 16496 KiB
06_concat_01.txt AC 221 ms 16512 KiB
06_concat_02.txt AC 217 ms 25780 KiB