模拟
糕点
http://www.nowcoder.com/questionTerminal/10661f4d02564ba686bcba4645e0a029
#include<bits/stdc++.h> using namespace std; const int maxn=1e5+5; int solve[maxn]; int myMin,myMax; int n,m,a,b; int main() { while( ~scanf("%d%d%d%d",&n,&m,&a,&b) ) { //使得a<=b if( a>b ) { swap(a,b); } myMin=0x3f3f3f; myMax=-1; for(int i=0; i<m; ++i) { scanf("%d",&solve[i]); myMax=max( myMax, solve[i] ); myMin=min( myMin, solve[i] ); } if( myMin<a || myMax>b ) { printf("NO\n"); continue; } int num=0; if( myMin==a ) { ++num; } if( myMax==b ) { ++num; } int tag=n-m; if( tag>=(2-num) ) { printf("YES\n"); } else { printf("NO\n"); } } return 0; }