This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define DEBUG false
using namespace std;
long long solve1(int N, int D, int M) {
vector <int> X(N + 1);
for(int i = 1; i <= N; i++) {
cin >> X[i];
}
sort(X.begin() + 1, X.end());
long long ans = 0;
for(int l = 1, r = 1; r <= N; r++) {
while(l < r and X[r] - X[l] > D) {
l++;
}
ans += r - l;
}
return ans;
}
long long solve2(int N, int D, int M) {
vector <int> X(N + 1, 0), Y(N + 1, 0);
return -1;
}
long long solve3(int N, int D, int M) {
return -1;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int B, N, D, M;
cin >> B >> N >> D >> M;
if(B == 1) {
cout << solve1(N, D, M);
}
else if(B == 2) {
cout << solve2(N, D, M);
}
else if(B == 3) {
cout << solve3(N, D, M);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |