General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
56070734 Practice:
wtltw
939F - 31 C++14 (GCC 6-32) Accepted 31 ms 3144 KB 2019-06-26 13:18:19 2019-06-26 13:18:20
→ Source
#include <bits/stdc++.h>
#define N 200006
using namespace std;
int n,k,l,r,q[N],q1[N],f[2][N];
int main()
{
	scanf("%d%d",&n,&k);
	memset(f,10,sizeof f);f[1][0]=0;
	for(int i=1;i<=k;i++){
		scanf("%d%d",&l,&r);
		for(int j=0;j<=n;j++)f[0][j]=f[1][j];
		memset(f[1],10,sizeof f[1]);
		int h=1,t=0,h1=1,t1=0;
		for(int j=min(r,n);j>l;j--){
			while(h<=t&&f[0][q[t]]>f[0][j])t--;
			q[++t]=j;
		}
		for(int j=0;j<=min(r,n);j++){
			while(h<=t&&q[h]>r-j)h++;
			if(l-j>=0){
				while(h<=t&&f[0][q[t]]>f[0][l-j])t--;
				q[++t]=l-j;
			}
			while(h1<=t1&&q1[h1]<j-r+l)h1++;
			while(h1<=t1&&f[0][q1[t]]>f[0][j])t1--;
			q1[++t1]=j;
			f[1][j]=min(min(2+f[0][q1[h1]],1+f[0][q[h]]),f[0][j]);
		}
	}
	if(f[1][n]<1e8)printf("Full\n%d\n",f[1][n]);else puts("Hungry");
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details