General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
108661707 Practice:
Moral_and_Law
939F - 31 GNU C++11 Accepted 31 ms 2360 KB 2021-02-28 14:22:15 2021-02-28 14:22:15
→ Source
#include <bits/stdc++.h>
#define N 200201
#define inf 0x3f3f3f3f
using namespace std;
int n,m,l,r,h,t,q[N],f[N][2];
int main(){
	int i,j,k;scanf("%d%d",&n,&m);
	memset(f,0x3f,sizeof(f));f[0][0]=0;
	for(i=1;i<=m;i++){
		scanf("%d%d",&l,&r);
		for(j=0;j<=n;j++) f[j][i&1]=f[j][i&1^1];
		h=1;t=0;
		for(j=r;j>=0;j--){
			while(h<=t&&q[h]<l-j) h++;
			while(h<=t&&f[q[t]][i&1^1]>f[r-j][i&1^1]) t--;
			q[++t]=r-j;f[j][i&1]=min(f[j][i&1],f[q[h]][i&1^1]+1);
		}
		h=1;t=0;
		for(j=0;j<=min(n,r);j++){
			while(h<=t&&q[h]<j+l-r) h++;
			while(h<=t&&f[q[t]][i&1^1]>f[j][i&1^1]) t--;
			q[++t]=j;f[j][i&1]=min(f[j][i&1],f[q[h]][i&1^1]+2);
		}
	}if(f[n][m&1]>=inf) puts("Hungry");
	else printf("Full\n%d\n",f[n][m&1]);
	return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details