General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
124942437 Practice:
houzhiyuan123
939F - 31 GNU C++11 Accepted 31 ms 6960 KB 2021-08-05 12:55:08 2021-08-05 12:55:08
 
 
→ Source
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+20;
int n,m,f[3][N],q[N];
void add(int &x,int y){x=min(x,y);}
int main(){
	memset(f,10,sizeof(f));
	f[0][0]=0;
	scanf("%d%d",&n,&m);
	int z=1;
	for(int i=1;i<=m;i++,z^=1){
		int l,r;
		scanf("%d%d",&l,&r);
		for(int j=0;j<=n;j++)f[z][j]=f[!z][j];
		int tail=0,head=1;
		for(int j=r;j>=0;j--){
			while(tail>=head&&q[head]<l-j)head++;
			while(tail>=head&&f[!z][r-j]<f[!z][q[tail]])tail--;
			q[++tail]=r-j;
			add(f[z][j],f[!z][q[head]]+1);
		}
		tail=0,head=1;
		for(int j=0;j<=min(n,r);j++){
			while(tail>=head&&q[head]<l-r+j)head++;
			while(tail>=head&&f[!z][j]<f[!z][q[tail]])tail--;
			q[++tail]=j;
			add(f[z][j],f[!z][q[head]]+2);
		}
	}
	if(f[!z][n]>1e8)puts("Hungry");
	else puts("Full"),printf("%d",f[!z][n]);
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details