Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 509;
- int a[N];
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- // freopen("/home/hamoudi/Coding/run.in", "r", stdin);
- freopen("overcode.in", "r", stdin);
- int tt = 1;
- cin >> tt;
- while (tt--) {
- int n;
- cin >> n;
- for (int i = 0; i < n; ++i) {
- cin >> a[i];
- }
- // i need to make the ratings in ascending order
- sort(a, a + n);
- int ans = 0;
- for (int i = 0; i < n; ++i) {
- // i need to check if the difference between maximum member and current member is less than or equal 1000
- // and it's a valid member (not out of range)
- if (i + 5 < n && a[i + 5] - a[i] <= 1000) {
- ans++;
- i += 5; // i will skip next 5 coders
- // in this case the team has been already formed
- }
- }
- cout << ans << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement