結果
| 問題 |
No.723 2つの数の和
|
| コンテスト | |
| ユーザー |
けーむ
|
| 提出日時 | 2020-03-13 10:56:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,006 bytes |
| コンパイル時間 | 1,706 ms |
| コンパイル使用メモリ | 176,632 KB |
| 実行使用メモリ | 15,392 KB |
| 最終ジャッジ日時 | 2024-11-21 17:49:20 |
| 合計ジャッジ時間 | 9,146 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 TLE * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
// ifstream in("input.txt");
// cin.rdbuf(in.rdbuf());
ll n, x;
cin >> n >> x;
vector<ll> a(n);
rep(i, n) cin >> a[i];
sort(all(a));
multiset<ll> ms;
rep(i, n) ms.insert(a[i]);
ll ans = 0;
rep(i, n) {
ll p = x - a[i];
if (p < a[i]) break;
if (p == a[i]) {
ll cnt = ms.count(p);
ans += cnt;
}
else {
ll cnt = ms.count(p);
ans += cnt * 2;
}
}
cout << ans << endl;
return 0;
}
けーむ