Submission #261163

#TimeUsernameProblemLanguageResultExecution timeMemory
261163stoyan_malininPairs (IOI07_pairs)C++14
30 / 100
30 ms1848 KiB
#include<iostream> #include<cstring> #include<vector> #include<algorithm> using namespace std; int b, n, d, m; void solve1() { vector <int> v; for(int i = 0;i<n;i++) { int x; cin >> x; v.push_back(x); } long long answer = 0; sort(v.begin(), v.end()); for(int i = 0;i<n-1;i++) { if(v[i+1]-v[i]>d) continue; int l = i + 1, r = n - 1, mid; while(l+1<r) { mid = (l+r)/2; if(v[mid]-v[i]<=d) l = mid; else r = mid - 1; } if(v[r]-v[i]<=d) answer += r - i; else answer += l - i; } cout << answer << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> b >> n >> d >> m; if(b==1) solve1(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...