# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
992689 |
2024-06-05T01:17:08 Z |
ezzzay |
Pairs (IOI07_pairs) |
C++14 |
|
4000 ms |
5072 KB |
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define int long long
const int N=3e5+5;
void sbtsk1(int N, int D , int M){
vector<int>v;
for(int i=0;i<N;i++){
int a;
cin>>a;
v.pb(a);
}
sort(v.begin(),v.end());
int cnt=0;
for(auto i=v.begin();i!=v.end();i++){
int a=*i;
auto it= upper_bound(v.begin(),v.end(),a-D-1);
cnt+= i-it;
}
cout<<cnt;
}
void sbtsk2(int N, int D , int M){
vector<pair<int,int>>v;
for(int i=0;i<N;i++){
int x,y;
cin>>x>>y;
v.pb({x,y});
}
int cnt=0;
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
int d=abs(v[i].ff-v[j].ff)+abs(v[i].ss-v[j].ss);
if(d<=D)cnt++;
}
}
cout<<cnt;
}
void sbtsk3(int N, int D, int M){
vector<pair<pair<int,int>,int>>v;
for(int i=0;i<N;i++){
int x,y,z;
cin>>x>>y>>z;
v.pb({{x,y},z});
}
int cnt=0;
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
int d=abs(v[i].ff.ff-v[j].ff.ff)+abs(v[i].ff.ss-v[j].ff.ss)+abs(v[i].ss-v[j].ss);
if(d<=D)cnt++;
}
}
cout<<cnt;
}
signed main(){
int B,N,D,M;
cin>>B>>N>>D>>M;
if(B==1){
sbtsk1(N,D,M);
return 0;
}
if(B==2){
sbtsk2(N,D,M);
return 0;
}
sbtsk3(N,D,M);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
1492 KB |
Output is correct |
2 |
Correct |
18 ms |
1492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
1492 KB |
Output is correct |
2 |
Correct |
28 ms |
1492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1488 KB |
Output is correct |
2 |
Correct |
31 ms |
1492 KB |
Output is correct |
3 |
Correct |
29 ms |
1492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4078 ms |
2512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4017 ms |
2512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4025 ms |
2500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4070 ms |
5072 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4014 ms |
3788 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4019 ms |
3832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |