fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. using namespace __gnu_pbds;
  4. #define FAST ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
  5. #define ll long long
  6. #define ld long double
  7. #define int long long
  8. #define endl "\n"
  9. #define yes cout<<"yes"<<endl
  10. #define no cout<<"no"<<endl
  11. #define pb push_back
  12. //#pragma GCC optimize("O3,unroll-loops")
  13. //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
  14. using namespace std;
  15. const int MOD = 1e9+7 ;
  16. //const int MOD = 998244353 ;
  17. const int N = 1e5+5 ;
  18. const ll INF = 1e18 ;
  19. const ll MIN = -1e18 ;
  20. typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
  21.  
  22.  
  23. void solve() {
  24. ll n,k;cin>>n>>k;
  25. vector<ll> a(n+2,0);
  26. vector<ll> pref1(n+2,0),pref2(n+2,0);
  27. for(int i=1;i<=n;i++){
  28. cin>>a[i];
  29. if(a[i]==k){
  30. pref1[i]++;
  31. }
  32. if(a[i]<k){
  33. pref2[i]++;
  34. }
  35. pref1[i]+=pref1[i-1];
  36. pref2[i]+=pref2[i-1];
  37. }
  38. if(n==1 && a[1]==k){
  39. yes;
  40. return;
  41. }
  42. ll test=0;
  43. for(int i=1;i<=n;i++){
  44. if(a[i]==k && (a[i-1]>=a[i] || a[i+1]>=a[i])){
  45. test=1;
  46. }
  47. }
  48. for(int i=3;i<=n;i++){
  49. if(a[i]==k && a[i-2]==k){
  50. test=1;
  51. }
  52. }
  53. if(test){
  54. yes;
  55. return;
  56. }
  57. no;
  58.  
  59. }
  60.  
  61. signed main() {
  62. FAST;
  63. auto begin = std::chrono::high_resolution_clock::now();
  64. #ifndef ONLINE_JUDGE
  65. freopen("input.txt","r",stdin);
  66. freopen("output.txt","w",stdout);
  67. #endif
  68. ll t=1;
  69. cin>>t;
  70. while(t--) solve();
  71. #ifndef ONLINE_JUDGE
  72. auto end = std::chrono::high_resolution_clock::now();
  73. cout << setprecision(4) << fixed;
  74. cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
  75. #endif
  76. }
  77.  
  78.  
  79.  
Success #stdin #stdout 0.09s 101776KB
stdin
Standard input is empty
stdout
no