# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
435144 |
2021-06-23T04:00:05 Z |
sumit_kk10 |
Pairs (IOI07_pairs) |
C++14 |
|
4000 ms |
2252 KB |
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
void solve(){
long long b, n, d, m;
cin >> b >> n >> d >> m;
long long ans = 0;
if(b == 1){
long long a[n];
for(int i = 0; i < n; ++i)
cin >> a[i];
sort(a, a + n);
for(int i = 0; i < n; ++i){
int low = i + 1, ok = -1, high = n - 1;
while(low <= high){
int mid = (low + high) / 2;
if(a[mid] - a[i] <= d){
ok = mid;
low = mid + 1;
}
else
high = mid - 1;
}
if(ok != -1)
ans += (ok - i);
}
cout << ans << '\n';
}
else if(b == 2){
pair<long long, long long> a[n];
for(int i = 0; i < n; ++i)
cin >> a[i].first >> a[i].second;
for(int i = 0; i < n; ++i){
for(int j = i + 1; j < n; ++j){
long long dis = abs(a[i].first - a[j].first);
dis += abs(a[i].second - a[j].second);
ans += (dis <= d);
}
}
cout << ans << '\n';
}
}
int main(){
fast;
int t = 1;
// cin >> t;
while(t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
1092 KB |
Output is correct |
2 |
Correct |
18 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
972 KB |
Output is correct |
2 |
Correct |
23 ms |
1072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1072 KB |
Output is correct |
2 |
Correct |
25 ms |
1096 KB |
Output is correct |
3 |
Correct |
37 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4070 ms |
1868 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4062 ms |
1996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4075 ms |
2252 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |