Submission #377526

# Submission time Handle Problem Language Result Execution time Memory
377526 2021-03-14T09:38:09 Z MilosMilutinovic Pairs (IOI07_pairs) C++14
30 / 100
32 ms 1792 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100050;
void Solve1D(){
    int n,d,m;scanf("%i%i%i",&n,&d,&m);
    vector<int> x(n);
    for(int i=0;i<n;i++)scanf("%i",&x[i]);
    sort(x.begin(),x.end());
    ll ans=0;
    for(int i=0,j=0;i<n;i++){
        while(j<n&&x[i]-x[j]>d)j++;
        ans+=i-j;
    }
    printf("%lld",ans);
}
int main(){
    int b;scanf("%i",&b);
    if(b==1)Solve1D();
}

Compilation message

pairs.cpp: In function 'void Solve1D()':
pairs.cpp:6:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    6 |     int n,d,m;scanf("%i%i%i",&n,&d,&m);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~
pairs.cpp:8:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     for(int i=0;i<n;i++)scanf("%i",&x[i]);
      |                         ~~~~~^~~~~~~~~~~~
pairs.cpp: In function 'int main()':
pairs.cpp:18:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |     int b;scanf("%i",&b);
      |           ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1132 KB Output is correct
2 Correct 17 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1644 KB Output is correct
2 Correct 21 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1664 KB Output is correct
2 Correct 22 ms 1516 KB Output is correct
3 Correct 21 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -