General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
132189895 Practice:
bkifhr9
939F - 31 GNU C++17 (64) Accepted 31 ms 2352 KB 2021-10-17 09:50:58 2021-10-17 09:50:58
 
 
→ Source
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define INF 0x3f3f3f3f
int h,t,q[N<<1];
int n,K,l,r,f[2][N<<1];
int main(){
	memset(f[0],0x3f,sizeof(f[0])); f[0][0]=0;
	scanf("%d%d",&n,&K);
	for(int i=1;i<=K;++i){
		scanf("%d%d",&l,&r);
		for(int j=0;j<=n;++j)
			f[i&1][j]=f[!(i&1)][j];
		h=1;t=0;
		for(int j=r;j>=0;--j){ 
			while(h<=t&&q[h]<l-j) ++h;
			while(h<=t&&f[!(i&1)][q[t]]>f[!(i&1)][r-j]) --t;
			q[++t]=r-j; f[i&1][j]=min(f[i&1][j],f[!(i&1)][q[h]]+1); 
		}
		h=1; t=0; 
		for(int j=0,mj=min(n,r);j<=mj;++j){ 
			while(h<=t&&q[h]<j-r+l) ++h;
			while(h<=t&&f[!(i&1)][q[t]]>f[!(i&1)][j]) --t;
			q[++t]=j; f[i&1][j]=min(f[i&1][j],f[!(i&1)][q[h]]+2);
		}
	}
	if(f[K&1][n]==INF)printf("Hungry\n");
	else printf("Full\n%d\n",f[K&1][n]);
}
						 		 	   		  		 	 	 	  	 	
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details