General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
133111232 Practice:
Hanoist
939F - 31 C++14 (GCC 6-32) Accepted 31 ms 3764 KB 2021-10-26 03:32:44 2021-10-26 03:32:45
→ Source
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1e5 + 1;
int L[N],R[N],Q[N],f[2][N << 1];
int main(){
	int i,j,n,k,l,r,front,rear;
	scanf("%d %d",&n,&k);
	memset(f,0x3f,sizeof(f));
	f[1][0] = 0;
	for(i = 1;i <= k;i++){
		scanf("%d %d",&l,&r);
		for(j = 0;j <= n;j++) f[0][j] = f[1][j];
		front = 1,rear = 0;
		for(j = r;j >= 0;j--){
			while(front <= rear && Q[front] < l - j) ++front;
			while(front <= rear && f[0][Q[rear]] > f[0][r - j]) --rear;
			Q[++rear] = r - j;
			f[1][j] = min(f[1][j],f[0][Q[front]] + 1);
		}
		front = 1,rear = 0;
		for(j = 0;j <= min(n,r);j++){
			while(front <= rear && Q[front] < j - r + l) ++front;
			while(front <= rear && f[0][Q[rear]] > f[0][j]) --rear;
			Q[++rear] = j;
			f[1][j] = min(f[1][j],f[0][Q[front]] + 2);
		}
	}
	if(f[1][n] > 1e9) printf("Hungry\n");
	else{
		printf("Full\n%d\n",f[1][n]);
	}
	return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details