Advertisement
Rofyda_Elghadban1

Untitled

Jan 26th, 2024
638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1.  #include <bits/stdc++.h>
  2.  #define ll long long
  3.  #define ull unsigned long long
  4.  #define pi 3.141592654
  5.  #define NUM 1e18
  6.  #define Mod  1'000'000'007
  7.  #define fixed(n) fixed<<setprecision(n)
  8.  #define cin(v) for(auto &i:v) cin >> i ;
  9.  #define cout(v) for(auto &i:v) cout << i  <<" ";
  10.  #define vowel(x) (x=='e'||x=='a'||x=='i'||x=='o'||x=='u')
  11.  #define small(x) (x>=97&&x<=122)
  12.  #define capital(x) (x>=65&&x<=90)
  13.  #define Tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
  14.  #define Toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
  15.  #define sz(x) (int)(x.size())
  16.  #define all(v) ((v).begin()), ((v).end())
  17.  #define allr(v) ((v).rbegin()), ((v).rend())
  18.  #define updmax(a,b) a=max(a,b)
  19.  #define updmin(a,b) a=min(a,b)
  20.  #define ceil(a,b) ((a/b)+(a%b?1:0))
  21.  /* asc -> 1 2 3 ,des -> 3 2 1 */
  22.  
  23.  /***********************************************************************************/
  24.  using namespace std;
  25.  void Rofyda_Elghadban(){
  26.   #ifndef ONLINE_JUDGE  
  27.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  28.    #endif
  29.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  30.  }
  31.  
  32.  bool student(int n,int s,vector<int>v){
  33.   sort(all(v));
  34.   for(int i=0;i<n;i++){
  35.     if((i+s-1)<n&&(v[i+s-1]-v[i])<=5&&s<=n){
  36.       return true;
  37.     }
  38.   }
  39.   return false;
  40.  }
  41.  
  42.  void solve(){
  43.   int n,s;
  44.   cin>>n>>s;
  45.   vector<int>v(n);
  46.   cin(v);
  47.   cout<<student(n,s,v)<<"\n";
  48.  }
  49.  
  50.  int main(){
  51.   Rofyda_Elghadban();
  52.   // int t;
  53.   // cin>>t;
  54.   // while(t--){
  55.   //   solve();
  56.   // }
  57.   solve();
  58.   return 0;
  59.  }
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement