Submission #1059645

# Submission time Handle Problem Language Result Execution time Memory
1059645 2024-08-15T06:42:29 Z KasymK Pairs (IOI07_pairs) C++17
30 / 100
17 ms 1812 KB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second	
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int b, n, d, m;
    scanf("%d%d%d%d", &b, &n, &d, &m);
    if(b == 1){
        vector<int> v;
        for(int i = 1; i <= n; ++i){
            int x;
            scanf("%d", &x);
            v.pb(x);
        }
        sort(all(v));
        ll answer = 0;
        for(auto I = v.begin(); I != v.end(); ++I){
            int x = *I;
            auto it = upper_bound(all(v), x-d-1);
            answer += (I-it);
        }
        printf("%lld\n", answer);
    }
    return 0;
}

Compilation message

pairs.cpp: In function 'int main()':
pairs.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d%d%d%d", &b, &n, &d, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp:20:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |             scanf("%d", &x);
      |             ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1236 KB Output is correct
2 Correct 12 ms 1436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1752 KB Output is correct
2 Correct 15 ms 1812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1752 KB Output is correct
2 Correct 16 ms 1752 KB Output is correct
3 Correct 15 ms 1620 KB Output is correct
# 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 352 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 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -