General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
45211936 Practice:
LiGuanlin
939F - 31 GNU C++11 Accepted 31 ms 1776 KB 2018-11-02 18:36:16 2018-11-02 18:36:16
 
 
→ Source
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100050
#define K 105
int n,k;
int f[2][2*N];
int q[N],hd,tl;
int main()
{
	scanf("%d%d",&n,&k);
	memset(f,0x3f,sizeof(f));
	f[0][0]=0;
	for(int l,r,now=1;now<=k;now++)
	{
		scanf("%d%d",&l,&r);
		memcpy(f[now&1],f[!(now&1)],sizeof(f[now&1]));
		hd=1,tl=0;
		for(int i=0;i<=r&&i<=n;i++)
		{
			while(hd<=tl&&f[!(now&1)][i]<=f[!(now&1)][q[tl]])tl--;
			q[++tl]=i;
			while(hd<=tl&&q[hd]+r-l<i)hd++;
			f[now&1][i]=min(f[now&1][i],f[!(now&1)][q[hd]]+2);
		}
		hd=1,tl=0;
		for(int i=r;i>=0;i--)
		{
			while(hd<=tl&&f[!(now&1)][q[tl]]>=f[!(now&1)][r-i])tl--;
			q[++tl]=r-i;
			while(hd<=tl&&q[hd]<l-i)hd++;
			f[now&1][i]=min(f[now&1][i],f[!(now&1)][q[hd]]+1);
		}
	}
	if(f[k&1][n]<=2000)
	{
		printf("Full\n%d\n",f[k&1][n]);
	}else
	{
		printf("Hungry\n");
	}
	return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details