General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
134670662 Practice:
A524
939F - 31 C++14 (GCC 6-32) Accepted 31 ms 4968 KB 2021-11-08 16:41:28 2021-11-08 16:41:28
→ Source
#include<bits/stdc++.h>
using namespace std;
int n,K,i,j,l,r,L[200200],R[200200],f[200200],g[200200],q[200200];
int main(){
	scanf("%d %d",&n,&K);
	for (i=1;i<=K;i++)scanf("%d%d",&L[i],&R[i]);
	memset(f,63,sizeof(f));f[0]=0;
	for (i=1;i<=K;i++){
		for (j=1;j<=n;j++) g[j]=f[j];
		for (l=1,r=0,j=R[i];j>=0;j--){
			while (l<=r&&g[q[r]]>=g[R[i]-j]) r--;
			q[++r]=R[i]-j;
			while (l<=r&&q[l]<L[i]-j) l++;
			f[j]=min(f[j],g[q[l]]+1);
		}
		for (l=1,r=j=0;j<=R[i];j++){
			while (l<=r&&g[q[r]]>=g[j]) r--;
			q[++r]=j;
			while (l<=r&&q[l]<j+L[i]-R[i]) l++;
			f[j]=min(f[j],g[q[l]]+2);
		}
	}
	if (f[n]>(1e9)) printf("Hungry\n");
	else printf("Full\n%d\n",f[n]);
	return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details