#2, 3, 4TLE, 求调
  • 板块P1102 A-B 数对
  • 楼主XmasCao
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/5/26 10:56
  • 上次更新2024/5/26 12:45:26
查看原帖
#2, 3, 4TLE, 求调
654093
XmasCao楼主2024/5/26 10:56
#include <bits/stdc++.h>
using namespace std;

#ifndef ONLINE_JUDGE
    #pragma GCC optimize(2)
#endif

#define OFF_SYNC ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cerr.tie(0), clog.tie(0);
#define endl "\n"

using _us  = unsigned;
using _s   = signed;
using _sll = signed long long;
using _ull = unsigned long long;
using _d   = double;
using _ld  = long double;

const _sll N   = 1010;
const _sll M   = 10010;
const _sll L   = 100010;
const _sll INF = 0x3f3f3f3f;

_sll n, c, g, ans;
vector<_sll> v;
int main() {
    OFF_SYNC
    cin >> n >> c;
    for (_sll i=0; i<n; i++) {
        cin >> g;
        v.push_back(g);
    }
    sort(v.begin(), v.end());
    for (auto i: v) {
        ans += count_if(v.begin(), v.end(), [&](_sll a)->bool{
            return a>i && a-i==c; 
        });
    }
    cout << ans;
    return 0;
}
2024/5/26 10:56
加载中...