Submission #76633143
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 5;
vector<int> a[N], b[N];
int s[N], t[N];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, d;
cin >> n >> d;
for(int i = 0; i < n; i++)
{
cin >> s[i] >> t[i];
a[s[i]].push_back(i);
b[t[i]].push_back(i);
}
set<int> st;
ll ans = 0;
for(int i = 1; i + d < N; i++)
{
for(int j : a[i])
{
if(t[j] >= i + d)
st.insert(j);
}
ll sz = st.size();
ans += sz * (sz - 1) / 2;
for(int j : b[i + d])
st.erase(j);
}
cout << ans << '\n';
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Accomplice |
| User | aaa65654 |
| Language | C++23 (GCC 15.2.0) |
| Score | 400 |
| Code Size | 738 Byte |
| Status | AC |
| Exec Time | 313 ms |
| Memory | 66972 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| All | 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, sample-01.txt, sample-02.txt, sample-03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 04.txt | AC | 13 ms | 3448 KiB |
| 05.txt | AC | 13 ms | 3572 KiB |
| 06.txt | AC | 67 ms | 15784 KiB |
| 07.txt | AC | 66 ms | 15704 KiB |
| 08.txt | AC | 24 ms | 6712 KiB |
| 09.txt | AC | 23 ms | 6584 KiB |
| 10.txt | AC | 21 ms | 6660 KiB |
| 11.txt | AC | 13 ms | 3988 KiB |
| 12.txt | AC | 17 ms | 9756 KiB |
| 13.txt | AC | 27 ms | 25460 KiB |
| 14.txt | AC | 93 ms | 54028 KiB |
| 15.txt | AC | 201 ms | 61452 KiB |
| 16.txt | AC | 146 ms | 62796 KiB |
| 17.txt | AC | 307 ms | 66964 KiB |
| 18.txt | AC | 313 ms | 66972 KiB |
| 19.txt | AC | 118 ms | 62324 KiB |
| 20.txt | AC | 177 ms | 63300 KiB |
| 21.txt | AC | 176 ms | 63308 KiB |
| 22.txt | AC | 174 ms | 63372 KiB |
| 23.txt | AC | 253 ms | 65656 KiB |
| sample-01.txt | AC | 12 ms | 3588 KiB |
| sample-02.txt | AC | 12 ms | 3476 KiB |
| sample-03.txt | AC | 12 ms | 3508 KiB |