General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
57945042 Practice:
vjudge5
939F - 31 GNU C++11 Accepted 46 ms 3532 KB 2019-07-29 17:00:17 2019-07-29 17:00:17
→ Source
#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;
int n,k,l,r,q[MAXN];
long long f[2][2*MAXN];
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) f[0][i]=1e8;
	for (int tot=1;tot<=k;tot++)
	{
		scanf("%d%d",&l,&r);
		for (int i=0;i<=n;i++)
			f[tot%2][i]=f[(tot+1)%2][i];
		int h=1,t=0;
		for (int i=0;i<=min(n,r);i++)
		{
			while (f[(tot+1)%2][i]<=f[(tot+1)%2][q[t]]&&h<=t) t--;
			q[++t]=i;
			while (q[h]<i-(r-l)&&h<=t) h++;
			f[tot%2][i]=min(f[tot%2][i],f[(tot+1)%2][q[h]]+2);
		}
		h=1,t=0;
		for (int i=r;i>=0;i--)
		{
			while (f[(tot+1)%2][r-i]<=f[(tot+1)%2][q[t]]&&h<=t) t--;
			q[++t]=r-i;
			while (q[h]<l-i&&h<=t) h++;
			f[tot%2][i]=min(f[tot%2][i],f[(tot+1)%2][q[h]]+1);
		}
	}
	if (f[k%2][n]>=1e8) printf("Hungry\n");
	else printf("Full\n"),printf("%lld\n",f[k%2][n]);
	return 0;
}
	  		    	 		 		 	   			  					
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details