General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
117297907 Practice:
QQH
939F - 31 GNU C++11 Accepted 31 ms 41496 KB 2021-05-25 10:48:54 2021-05-25 10:48:54
 
 
→ Source
#include<bits/stdc++.h>
using namespace std;
const int N=100005,T=105;
int n,t,f[T][N],q[N];
int main(){
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;i++)f[0][i]=2e9;
	for(int i=1;i<=t+1;i++){
		int l,r;
		if(i==t+1)l=r=n*2;
		else scanf("%d%d",&l,&r);
		for(int j=0;j<=n;j++)f[i][j]=f[i-1][j];
		int he=1,ta=0;
		for(int j=0;j<=n;j++){
			while(he<=ta&&f[i-1][q[ta]]>=f[i-1][j])--ta;
			q[++ta]=j;
			while(q[he]<j-(r-l))++he;
			f[i][j]=min(f[i][j],f[i-1][q[he]]+2);
			if(r>=j&&r-j<=n)f[i][r-j]=min(f[i][r-j],f[i-1][q[he]]+1);
		}
	}
	if(f[t+1][n]==2e9){
		puts("Hungry");
		return 0;
	}
	puts("Full");
	printf("%d",f[t+1][n]);
	return 0;
} 
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details