# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
872254 |
2023-11-12T15:45:34 Z |
Matjaz |
Pairs (IOI07_pairs) |
C++14 |
|
4000 ms |
7176 KB |
//
// IOI2007Pairs.cpp
//
//
// Created by Matjaz Leonardis on 12/11/2023.
//
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int B,N,D,M;
int main(){
cin >> B >> N >> D >> M;
vector<vector<int> > c(N, vector<int> (B));
for (int i=0;i<N;i++){
for (int j=0;j<B;j++) cin >> c[i][j];
}
if (B == 1){
long long pairs = 0;
vector<int> x(N);
for (int i=0;i<N;i++) x[i] = c[i][0];
sort(x.begin(), x.end());
for (int i=0;i<N;i++){
vector<int>::iterator start = lower_bound(x.begin(), x.end(), x[i] - D);
vector<int>::iterator end = upper_bound(x.begin(), x.end(), x[i] + D);
pairs += (end - start) - 1;
}
cout << pairs / 2 << endl;
} else {
long long pairs=0;
for (int i=0;i<N;i++){
for (int j=i+1;j<N;j++){
long long distance = 0;
for (int k=0;k<B;k++) distance += abs(c[i][k] - c[j][k]);
if (distance <= D) pairs++;
}
}
cout << pairs << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
6324 KB |
Output is correct |
2 |
Correct |
27 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
6172 KB |
Output is correct |
2 |
Correct |
43 ms |
6992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
6308 KB |
Output is correct |
2 |
Correct |
47 ms |
7168 KB |
Output is correct |
3 |
Correct |
48 ms |
7176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4059 ms |
5724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4010 ms |
5720 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4016 ms |
5976 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4026 ms |
5724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4018 ms |
5720 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4010 ms |
5720 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |