Submission #386304

#TimeUsernameProblemLanguageResultExecution timeMemory
386304AmineTrabelsiPairs (IOI07_pairs)C++14
30 / 100
58 ms1644 KiB
#include <bits/stdc++.h> using namespace std; long long solve_D(){ int n,d,m; cin>>n>>d>>m; vector<int> a(n); for(auto &i:a)cin>>i; sort(a.begin(),a.end()); int p = 0; long long res = 0; for(int i=0;i<n;i++){ while(p < i && a[i]-a[p] > d)p++; res += i-p; } return res; } int main(){ int b; cin>>b; if(b == 1)cout<<solve_D()<<'\n'; else cout<<"to do\n"; return 0; } /* 1 6 5 100 10 20 23 25 50 50 1 */
#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...