Submission #73108684
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,a[610000];
int sum[610000];
int ams[610000],cnt;
signed main()
{
cin >> n;
for(int i = 1;i <= n;i++)
{
cin >> a[i];
}
sort(a + 1,a + n + 1);
bool ok = true;
int ans = a[1] + a[n];
ok = true;
for(int i = 2,j = n - 1;i < j;i++,j--)
{
int res = a[i] + a[j];
if(ans != res)
{
ok = false;
}
}
if(n % 2 == 1 && a[n / 2 + 1] != ans){ok = false;}
if(ok && ams[cnt] != ans){cnt++;ams[cnt] = ans;}
int x = a[n];
for(int i = 1;i <= n;i++){sum[i] = sum[i - 1] + a[i];}
ok = true;
for(int i = 1;i <= n;i++)
{
int r = i;
while(r < n)
{
if(sum[r] - sum[i - 1] == x)
{
break;
}
r++;
if(sum[r] - sum[i - 1] == x)
{
break;
}
}
if(sum[r] - sum[i - 1] == x)
{
i = r;
}
else
{
ok = false;
break;
}
}
if(ok && ams[cnt] != x)
{
cnt++;
ams[cnt] = x;
}
sort(ams + 1,ams + cnt + 1);
for(int i = 1;i <= cnt;i++)
{
cout << ams[i] << " ";
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - AtCoder Riko |
| User | sanjiaozhou |
| Language | C++23 (GCC 15.2.0) |
| Score | 0 |
| Code Size | 1059 Byte |
| Status | WA |
| Exec Time | 102 ms |
| Memory | 8416 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 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 | 3588 KiB |
| 0_sample_2.txt | AC | 1 ms | 3592 KiB |
| 0_sample_3.txt | AC | 1 ms | 3556 KiB |
| 1_1.txt | WA | 99 ms | 8404 KiB |
| 1_2.txt | WA | 94 ms | 8096 KiB |
| 1_3.txt | WA | 96 ms | 8324 KiB |
| 1_4.txt | WA | 96 ms | 8348 KiB |
| 1_5.txt | WA | 97 ms | 8396 KiB |
| 2_1.txt | AC | 100 ms | 8416 KiB |
| 2_2.txt | AC | 100 ms | 8324 KiB |
| 2_3.txt | AC | 102 ms | 8292 KiB |
| 2_4.txt | AC | 102 ms | 8244 KiB |
| 3_1.txt | WA | 101 ms | 8328 KiB |
| 3_2.txt | WA | 101 ms | 8416 KiB |
| 3_3.txt | WA | 97 ms | 8228 KiB |
| 3_4.txt | WA | 83 ms | 8292 KiB |
| 3_5.txt | AC | 1 ms | 3592 KiB |
| 3_6.txt | AC | 91 ms | 8152 KiB |
| 4_1.txt | AC | 32 ms | 8228 KiB |
| 4_2.txt | AC | 90 ms | 8256 KiB |
| 4_3.txt | AC | 1 ms | 3664 KiB |
| 4_4.txt | AC | 1 ms | 3616 KiB |