# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
483909 | 2021-11-01T10:24:36 Z | blue | Pairs (IOI07_pairs) | C++17 | 0 ms | 0 KB |
#include <iostream> #include <vector> using namespace std; void solve_1() { int N, D, M; cin >> N >> D >> M; vector<int> A(N); for(int i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); long long ans = 0; int j = 0; for(int i = 0; i < N; i++) { while(j+1 < N && A[j+1] - A[i] <= D) j++; ans += (j-i); } cout << ans << '\n'; } void solve_2() { ; } void solve_3() { ; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int B; cin >> B; if(B == 1) solve_1(); else if(B == 2) solve_2(); else if(B == 3) solve_3(); }