Submission #239098

#TimeUsernameProblemLanguageResultExecution timeMemory
239098T0p_Pairs (IOI07_pairs)C++14
30 / 100
41 ms1664 KiB
#include<bits/stdc++.h> using namespace std; int arr[100100]; int main() { int t, n, k, m; long long ans = 0; scanf(" %d %d %d %d",&t,&n,&k,&m); if(t == 1) { for(int i=1 ; i<=n ; i++) scanf(" %d",&arr[i]); sort(arr+1, arr+n+1); for(int i=1 ; i<=n ; i++) { int l = i, r = n; while(l != r) { int mid = (l+r+1)>>1; if(arr[mid] <= arr[i]+k) l = mid; else r = mid-1; } ans += l-i; } printf("%lld\n",ans); return 0; } return 0; }

Compilation message (stderr)

pairs.cpp: In function 'int main()':
pairs.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %d %d %d %d",&t,&n,&k,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp:14:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %d",&arr[i]);
    ~~~~~^~~~~~~~~~~~~~~
#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...