# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134024 | 2019-07-21T23:46:00 Z | dragonslayerit | Pairs (IOI07_pairs) | C++14 | 4000 ms | 2672 KB |
#include <cstdio> #include <vector> #include <algorithm> #include <array> int main(){ int B,N,D,M; scanf("%d %d %d %d",&B,&N,&D,&M); if(B==1){ std::vector<int> xs; for(int i=0;i<N;i++){ int X; scanf("%d",&X); xs.push_back(X); } std::sort(xs.begin(),xs.end()); long long ans=0; int j=0; for(int i=0;i<N;i++){ while(xs[i]-xs[j]>D) j++; ans+=i-j; } printf("%lld\n",ans); }else if(B==2){ std::vector<std::array<int,2> > ps; for(int i=0;i<N;i++){ int X,Y; scanf("%d %d",&X,&Y); ps.push_back({X,Y}); } std::sort(ps.begin(),ps.end()); long long ans=0; for(int i=0;i<N;i++){ for(int j=i+1;j<N;j++){ if(std::abs(ps[i][0]-ps[j][0])+std::abs(ps[i][1]-ps[j][1])<=D){ ans++; } } } printf("%lld\n",ans); }else if(B==3){ std::vector<std::array<int,3> > ps; for(int i=0;i<N;i++){ int X,Y,Z; scanf("%d %d %d",&X,&Y,&Z); ps.push_back({X,Y,Z}); } std::sort(ps.begin(),ps.end()); long long ans=0; for(int i=0;i<N;i++){ for(int j=i+1;j<N;j++){ if(std::abs(ps[i][0]-ps[j][0])+std::abs(ps[i][1]-ps[j][1])+std::abs(ps[i][2]-ps[j][2])<=D){ ans++; } } } printf("%lld\n",ans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 1012 KB | Output is correct |
2 | Correct | 20 ms | 1012 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 1012 KB | Output is correct |
2 | Correct | 27 ms | 984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 1012 KB | Output is correct |
2 | Correct | 28 ms | 1012 KB | Output is correct |
3 | Correct | 26 ms | 1012 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4010 ms | 2032 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4030 ms | 2160 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4034 ms | 2288 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 4 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4024 ms | 2612 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4051 ms | 2668 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4061 ms | 2672 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |