test sai

Rimuru Tempest 2025-12-04 3:28:57 2025-12-04 3:30:14

test sai nhe

input: 7 3 1 2 4 5 7 8 10 extended output: 5 output (theo đề bài cho): 4 (Sai so với code full AC)

code tham khảo:

C++ 17

#include #include #include using namespace std; typedef long long ll; typedef vector vi;

int main() { ios::sync_with_stdio(0); cin.tie(0);

int N,K; cin >> N >> K;
vi A(N);
for(int i=0;i<N;i++) cin >> A[i];

ll cnt = 0;
for(int i=0;i<N;i++) {
    int t = A[i]+K;
    auto l = lower_bound(A.begin()+i+1, A.end(), t);
    auto r = upper_bound(A.begin()+i+1, A.end(), t);
    cnt += (r-l);
}
cout << cnt << '\n';
return 0;

}

Tổng cộng 2 trả lời

Trần Tiến Minh

cam on mao le

Trần Tiến Minh