Submission #73070639
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fix(x) fixed << setprecision(x)
#define rep(i, start, end) for (auto i = (start); (i) < (end); (i)++)
#define repe(i, start, end) for (auto i = (start); (i) <= (end); (i)++)
#define rrep(i, start, end) for (auto i = (start); (i) >= (end); (i)--)
constexpr auto PI = 3.14159265358979;
constexpr int INF = 1e+9;
constexpr long long INFL = 1e+18;
using ll = long long;
using lld = long double;
// using mint = modint1000000007;
using mint = modint998244353;
using Pair_int = pair<int, int>;
using Pair_ll = pair<ll, ll>;
template <class T>
using Graph = vector<vector<T>>;
template <class T1, class T2>
inline auto div_floor(T1 a, T2 b)
{
if (b < 0)
a *= -1, b *= -1;
if (a >= 0)
return a / b;
else
return (a + 1) / b - 1;
}
template <class T1, class T2>
inline auto div_ceil(T1 a, T2 b)
{
if (b < 0)
a *= -1, b *= -1;
if (a <= 0)
return a / b;
else
return (a - 1) / b + 1;
}
ll floor_sqrt(ll x)
{
ll y = sqrt(x);
while (y * y > x)
y--;
while ((y + 1) * (y + 1) <= x)
y++;
return y;
}
ll pow_int(ll x, ll n)
{
ll res = 1;
while (n > 0)
{
if (n & 1)
res *= x;
x *= x;
n >>= 1;
}
return res;
}
ll pow_mod(ll x, ll n, ll mod)
{
ll res = 1;
while (n > 0)
{
if (n & 1)
res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
ll gcd(ll x, ll y)
{
if (x < y)
swap(x, y);
ll r;
while (y > 0)
{
r = x % y;
x = y;
y = r;
}
return x;
}
ll lcm(ll x, ll y) { return ll(x / gcd(x, y)) * y; }
ll nCk(ll n, ll r)
{
if (r < 0 || n < r)
return 0;
ll ans = 1;
for (ll i = 1; i <= r; i++)
{
ans *= n--;
ans /= i;
}
return ans;
}
int get_rand(int seed, int min, int max)
{
static mt19937_64 mt64(seed);
uniform_int_distribution<int> get_rand_int(min, max);
return get_rand_int(mt64);
}
template <typename T>
inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template <typename T>
inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }
template <class T1, class T2>
inline auto mod(T1 x, T2 r) { return (x % r + r) % r; }
// ======================================== //
int main()
{
int N;
cin >> N;
vector<ll> A(N);
rep(i, 0, N) cin >> A[i];
sort(all(A));
set<ll> ans;
if (A[0] == A[N - 1])
ans.insert(A[0]);
for (int m = 2; m <= N; m += 2)
{
ll L = A[0] + A[m - 1];
if (m < N)
{
if (A[m] != L || A[N - 1] != L)
continue;
}
bool flag = true;
rep(i, 1, m / 2)
{
if (A[i] + A[m - 1 - i] != L)
{
flag = false;
break;
}
}
if (flag)
ans.insert(L);
}
for (auto &&x : ans)
{
cout << x << " ";
}
cout << endl;
return 0;
}
Submission Info
| Submission Time |
|
| Task |
C - AtCoder Riko |
| User |
Yuulis |
| Language |
C++23 (GCC 15.2.0) |
| Score |
350 |
| Code Size |
3268 Byte |
| Status |
AC |
| Exec Time |
108 ms |
| Memory |
5812 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
350 / 350 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
0_sample_1.txt, 0_sample_2.txt, 0_sample_3.txt |
| All |
0_sample_1.txt, 0_sample_2.txt, 0_sample_3.txt, 1_1.txt, 1_2.txt, 1_3.txt, 1_4.txt, 1_5.txt, 2_1.txt, 2_2.txt, 2_3.txt, 2_4.txt, 3_1.txt, 3_2.txt, 3_3.txt, 3_4.txt, 3_5.txt, 3_6.txt, 4_1.txt, 4_2.txt, 4_3.txt, 4_4.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 0_sample_1.txt |
AC |
1 ms |
3556 KiB |
| 0_sample_2.txt |
AC |
1 ms |
3488 KiB |
| 0_sample_3.txt |
AC |
1 ms |
3640 KiB |
| 1_1.txt |
AC |
98 ms |
5732 KiB |
| 1_2.txt |
AC |
95 ms |
5680 KiB |
| 1_3.txt |
AC |
96 ms |
5728 KiB |
| 1_4.txt |
AC |
96 ms |
5788 KiB |
| 1_5.txt |
AC |
96 ms |
5788 KiB |
| 2_1.txt |
AC |
101 ms |
5728 KiB |
| 2_2.txt |
AC |
100 ms |
5676 KiB |
| 2_3.txt |
AC |
102 ms |
5780 KiB |
| 2_4.txt |
AC |
108 ms |
5708 KiB |
| 3_1.txt |
AC |
101 ms |
5792 KiB |
| 3_2.txt |
AC |
101 ms |
5732 KiB |
| 3_3.txt |
AC |
97 ms |
5728 KiB |
| 3_4.txt |
AC |
84 ms |
5680 KiB |
| 3_5.txt |
AC |
1 ms |
3584 KiB |
| 3_6.txt |
AC |
90 ms |
5812 KiB |
| 4_1.txt |
AC |
31 ms |
5680 KiB |
| 4_2.txt |
AC |
90 ms |
5728 KiB |
| 4_3.txt |
AC |
1 ms |
3464 KiB |
| 4_4.txt |
AC |
1 ms |
3692 KiB |