Submission #1053498

# Submission time Handle Problem Language Result Execution time Memory
1053498 2024-08-11T12:38:54 Z Dennis_Jason Pairs (IOI07_pairs) C++14
30 / 100
14 ms 2136 KB
#include <bits/stdc++.h>
#define NMAX 100001
#define int long long
#define pb push_back
#define eb emplace_back
#define MOD 1000000007
#define nl '\n'
#define INF  1000000007
#define LLONG_MAX 9223372036854775807
#define pii pair<int,int>
#define tpl tuple<int,int,int,int>
//#pragma GCC optimize("O3")
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
/*
 *
 *
    ----------------DEMONSTRATION-------------------

    ---------------------END------------------------

 */
/*-------------Initialize------------*/
int b,n,d,m;
int v[NMAX];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>b>>n>>d>>m;
    if(b==1)
    {
        for(int i=1;i<=n;++i)
        {
            cin>>v[i];
        }
        sort(v+1,v+1+n);
        int res=0;
        for(int i=1;i<=n;++i)
        {
            int st=i+1;
            int dr=n;
            int ans=-1;
            while(st<=dr)
            {
                int mid=(st+dr)/2;
                if(abs(v[i]-v[mid])<=d)
                {
                    ans=mid;
                    st=mid+1;
                }
                else
                    dr=mid-1;
            }
            if(ans==-1)
                continue;
            res+=(ans-i);
        }
        cout<<res;
    }

    return 0;
}

Compilation message

pairs.cpp:9: warning: "LLONG_MAX" redefined
    9 | #define LLONG_MAX 9223372036854775807
      | 
In file included from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:195,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:34,
                 from /usr/include/c++/10/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:39,
                 from pairs.cpp:1:
/usr/include/limits.h:135: note: this is the location of the previous definition
  135 | #  define LLONG_MAX __LONG_LONG_MAX__
      |
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1628 KB Output is correct
2 Correct 9 ms 1636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1884 KB Output is correct
2 Correct 13 ms 2080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1884 KB Output is correct
2 Correct 14 ms 1884 KB Output is correct
3 Correct 13 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -