結果
問題 |
No.723 2つの数の和
|
ユーザー |
|
提出日時 | 2020-01-18 11:23:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 699 bytes |
コンパイル時間 | 1,588 ms |
コンパイル使用メモリ | 171,604 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-27 04:22:41 |
合計ジャッジ時間 | 3,370 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1000000000 int main() { int n, m; cin >> n >> m; vector<int> a(n); for(int i=0;i<n;i++) { cin >> a[i]; } sort(a.begin(), a.end()); int p; int upper; int lower; int ans = 0; for(int i=0;i<n;i++) { p = a[i]; lower = distance(a.begin(), lower_bound(a.begin(), a.end(), m-p)); upper = distance(a.begin(), upper_bound(a.begin(), a.end(), m-p)); //cout << lower << " " << upper << endl; if(lower != 0) { if(p == m-p) ans+=upper-lower; else ans+=(upper-lower)*2; } } cout << ans << endl; }