結果
問題 | No.723 2つの数の和 |
ユーザー | けーむ |
提出日時 | 2020-03-13 10:56:12 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,006 bytes |
コンパイル時間 | 2,050 ms |
コンパイル使用メモリ | 176,600 KB |
実行使用メモリ | 13,896 KB |
最終ジャッジ日時 | 2024-05-01 13:12:17 |
合計ジャッジ時間 | 5,817 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
13,884 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 29 ms
6,940 KB |
testcase_04 | AC | 46 ms
8,192 KB |
testcase_05 | AC | 40 ms
7,680 KB |
testcase_06 | AC | 34 ms
8,192 KB |
testcase_07 | AC | 15 ms
6,944 KB |
testcase_08 | AC | 16 ms
6,940 KB |
testcase_09 | AC | 37 ms
8,448 KB |
testcase_10 | AC | 17 ms
6,940 KB |
testcase_11 | AC | 4 ms
6,944 KB |
testcase_12 | AC | 19 ms
6,940 KB |
testcase_13 | AC | 53 ms
8,832 KB |
testcase_14 | AC | 11 ms
6,944 KB |
testcase_15 | AC | 21 ms
6,944 KB |
testcase_16 | AC | 31 ms
6,940 KB |
testcase_17 | AC | 46 ms
7,680 KB |
testcase_18 | TLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
ソースコード
#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; }