Submission #954371

# Submission time Handle Problem Language Result Execution time Memory
954371 2024-03-27T17:27:32 Z codefox Pairs (IOI07_pairs) C++14
30 / 100
15 ms 1124 KB
#include<bits/stdc++.h>

using namespace std;

#define pii pair<int, int>
#define ll long long

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int b, n, d, m;
    cin >> b >> n >> d >> m;

    if (b == 1)
    {
        vector<int> nums(n);
        for (int i =0; i < n; i++) cin >> nums[i];
        sort(nums.begin(), nums.end());

        ll sol = 0;
        queue<int> q;
        for (int i = 0; i < n; i++)
        {
            while (q.size() && nums[i]-q.front()> d) q.pop();
            sol += q.size();
            q.push(nums[i]);
        }
        cout << sol;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 604 KB Output is correct
2 Correct 11 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 604 KB Output is correct
2 Correct 15 ms 1124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 856 KB Output is correct
2 Correct 14 ms 860 KB Output is correct
3 Correct 14 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -