結果
| 問題 |
No.723 2つの数の和
|
| コンテスト | |
| ユーザー |
wonda_t_coffee
|
| 提出日時 | 2020-04-05 12:08:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 2,226 bytes |
| コンパイル時間 | 1,223 ms |
| コンパイル使用メモリ | 111,156 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-03 08:06:33 |
| 合計ジャッジ時間 | 2,240 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>
#define fix(n) cout<<fixed<<setprecision(n)
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
#define uniq(a) sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a) reverse(all(a))
#define ctos(c) string(1, (c))
#define out(d) cout << (d)
#define outl(d) std::cout<<(d)<<"\n"
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define ceil(x, y) ((x + y - 1) / (y))
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb push_back
#define fst first
#define int long long
#define INF __LONG_LONG_MAX__
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void solve() {
ll N, X; cin >> N >> X;
const ll MAX = 100000;
vector<ll> nums(MAX+1, 0);
rep(i, N) {
ll ai; cin >> ai;
nums[ai]++;
}
ll ans = 0;
for (int i = 0; i <= min(MAX, X); i++) {
ll t = X - i, tmp;
if (X-i > MAX) continue;
if (i == t) tmp = nums[i] * nums[i];
else tmp = nums[i] * nums[t];
// debug2(i, tmp);
ans += tmp;
}
outl(ans);
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
srand((unsigned)time(NULL));
fix(12);
solve();
}
wonda_t_coffee