Submission #134023

# Submission time Handle Problem Language Result Execution time Memory
134023 2019-07-21T23:42:04 Z dragonslayerit Pairs (IOI07_pairs) C++14
30 / 100
30 ms 1012 KB
#include <cstdio>
#include <vector>
#include <algorithm>

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);
  }
}

Compilation message

pairs.cpp: In function 'int main()':
pairs.cpp:7:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d",&B,&N,&D,&M);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp:12:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d",&X);
       ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1012 KB Output is correct
2 Correct 21 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1012 KB Output is correct
2 Correct 29 ms 1012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1012 KB Output is correct
2 Correct 29 ms 1012 KB Output is correct
3 Correct 27 ms 884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 128 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -