結果
| 問題 |
No.723 2つの数の和
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-25 12:08:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 184 ms / 2,000 ms |
| コード長 | 1,949 bytes |
| コンパイル時間 | 3,432 ms |
| コンパイル使用メモリ | 223,136 KB |
| 実行使用メモリ | 20,536 KB |
| 最終ジャッジ日時 | 2025-03-25 12:08:28 |
| 合計ジャッジ時間 | 7,233 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define isin(l, x, r) (l <= x && x < r)
#define rep(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define rep3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define rep_r(i, n) for (int i = (int)(n) - 1; (i) >= 0; --(i))
#define rep3r(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); --(i))
#define all(x) begin(x), end(x)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using PI = std::pair<int, int>;
using PLL = std::pair<ll, ll>;
using VI = std::vector<int>;
using VLL = std::vector<ll>;
template <typename T>
using PQ = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <typename T>
bool chmax(T &a, const T &b) {
if (a < b) {
a = b; // aをbで更新
return true;
}
return false;
}
template <typename T>
bool chmin(T &a, const T &b) {
if (a > b) {
a = b; // aをbで更新
return true;
}
return false;
}
/*
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
cout << std::fixed << std::setprecision(15) << y << endl;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
*/
/*
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
*/
#include <atcoder/convolution>
using namespace atcoder;
using mint = modint998244353;
#ifdef LOCAL
#include <debug.h>
#else
#define dlog(...)
#endif
ll solve(int N, ll K, const std::vector<ll> &A) {
auto mx = *max_element(all(A));
VLL a(mx * 2 + 10);
rep(i, N) a[A[i]]++;
if (K > mx * 2) return 0;
auto c = convolution_ll(a, a);
return c[K];
}
// generated by oj-template v4.8.1 (https://github.com/online-judge-tools/template-generator)
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cout << std::fixed << std::setprecision(15);
int n;
ll k;
std::cin >> n;
std::vector<ll> a(n);
std::cin >> k;
rep(i, n) {
std::cin >> a[i];
}
auto ans = solve(n, k, a);
std::cout << ans << '\n';
return 0;
}