General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
119118510 Practice:
bkifhr8
939F - 31 C++17 (GCC 7-32) Accepted 31 ms 2332 KB 2021-06-11 08:27:19 2021-06-11 08:27:19
→ Source
#include<cstdio>
#include<algorithm>
#define N 100007
using namespace std;
int q[2*N],n,k,l,r,f[2][2*N];
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=2*n;i++)
        f[0][i]=1e5;
	f[0][0]=0;
	for (int i=1;i<=k;i++){
		scanf("%d%d",&l,&r);
		for (int j=0;j<=n;j++)
			f[1][j]=f[0][j];
		int h=1,t=0;
		for (int j=r;j>=0;j--){
			while (h<=t&&q[h]<l-j) h++;
			while (h<=t&&f[0][q[t]]>f[0][r-j]) t--;
			q[++t]=r-j;
			f[1][j]=min(f[1][j],f[0][q[h]]+1);
		}
		h=1,t=0;
		for (int j=0;j<=r;j++){
			while (h<=t&&q[h]<j-r+l) h++;
			while (h<=t&&f[0][q[t]]>f[0][j]) t--;
			q[++t]=j;
			f[1][j]=min(f[1][j],f[0][q[h]]+2);
		}
		for (int j=0;j<=2*n;j++)
            f[0][j]=f[1][j];
	}
	if (f[0][n]==1e5)
        printf("Hungry\n");
	else
        printf("Full\n%d\n",f[0][n]);
}

 	  	 						 						 					   	 	
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details