Skip to content

Commit

Permalink
Add 31637.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Sep 1, 2024
1 parent e1a457f commit 659658d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions 31xxx/31637.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

bool solve(void) {
int n, d; cin >> n >> d;
vector<int> a(2*n);
for (int i=0; i<2*n; i++) cin >> a[i];
sort(a.begin(), a.end());

for (int i=0; i<2*n; i+=2) {
if (a[i+1] - a[i] > d) return false;
}
return true;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

cout << (solve() ? "Yes" : "No");
return 0;
}

0 comments on commit 659658d

Please sign in to comment.