結果
| 問題 |
No.723 2つの数の和
|
| コンテスト | |
| ユーザー |
Esire
|
| 提出日時 | 2018-08-07 00:37:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,131 bytes |
| コンパイル時間 | 1,627 ms |
| コンパイル使用メモリ | 73,492 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-19 18:18:55 |
| 合計ジャッジ時間 | 2,343 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 7 RE * 5 |
ソースコード
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
//最大公約数: gcd()
//最小公倍数: lcm()
#define ll long long int
using namespace std;
template <typename T>
void in(T &t){ //標準入力
cin >> t;
return;
}
template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
sort(v.begin(), v.end(), std::greater<int>());
return;
}
template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
sort(v.begin(), v.end(), std::less<int>());
return;
}
int main(){
ll n, x, temp, count = 0;
vector<int> v(100001, 0);
cin >> n >> x;
for(ll i = 0; i < n; i++){
cin >> temp;
v[temp]++;
}
for(ll i = 0; i <= 50000; i++){
if(i >= x - i){
if(i == x - i && v[i] != 0) count += v[i];
break;
}
if(v[i] != 0 && v[x - i] != 0){
count += v[i] * v[x - i] * 2;
}
}
cout << count << endl;
return 0;
}
Esire