Submission #75376526
Source Code Expand
Copy
#include <stdio.h>#include <stdlib.h>int cmp(const void* x, const void* y) {int a = *(const int*)x, b = *(const int*)y;return (a > b) - (a < b);}int N;int A[312345];int dekimasuka(int last) {int i;int target;if (last < 1 || last % 2 == 0) return 0;target = A[0] + A[last];for (i = 1; i < last - i; i++) {if (A[i] + A[last - i] != target) return 0;}return 1;}int is_first = 1;void kotaeru(int ans) {printf(" %d" + is_first, ans);is_first = 0;}int main(void) {int i;int firstmax;if (scanf("%d", &N) != 1) return 1;for (i = 0; i < N; i++) {if (scanf("%d", &A[i]) != 1) return 1;}qsort(A, N, sizeof(*A), cmp);for (i = N - 1; A[i] == A[N - 1]; i--);firstmax = i + 1;if ((firstmax > 1 && A[0] + A[firstmax - 1] == A[N - 1] && dekimasuka(firstmax - 1)) ||firstmax == 0
#include <stdio.h>
#include <stdlib.h>
int cmp(const void* x, const void* y) {
int a = *(const int*)x, b = *(const int*)y;
return (a > b) - (a < b);
}
int N;
int A[312345];
int dekimasuka(int last) {
int i;
int target;
if (last < 1 || last % 2 == 0) return 0;
target = A[0] + A[last];
for (i = 1; i < last - i; i++) {
if (A[i] + A[last - i] != target) return 0;
}
return 1;
}
int is_first = 1;
void kotaeru(int ans) {
printf(" %d" + is_first, ans);
is_first = 0;
}
int main(void) {
int i;
int firstmax;
if (scanf("%d", &N) != 1) return 1;
for (i = 0; i < N; i++) {
if (scanf("%d", &A[i]) != 1) return 1;
}
qsort(A, N, sizeof(*A), cmp);
for (i = N - 1; A[i] == A[N - 1]; i--);
firstmax = i + 1;
if (
(firstmax > 1 && A[0] + A[firstmax - 1] == A[N - 1] && dekimasuka(firstmax - 1)) ||
firstmax == 0
) {
kotaeru(A[N - 1]);
}
if (dekimasuka(N - 1)) {
kotaeru(A[0] + A[N - 1]);
}
putchar('\n');
return 0;
}
/*
a + b = L
a を増やす → b を減らさなければならない
・最小と最大を組み合わせる (全部分かれた)
・最大が L で、最小とセカンドベストを組み合わせる
しかない
*/
Submission Info
| Submission Time | |
|---|---|
| Task | C - AtCoder Riko |
| User | mikecat |
| Language | C23 (GCC 14.2.0) |
| Score | 350 |
| Code Size | 1234 Byte |
| Status | AC |
| Exec Time | 50 ms |
| Memory | 4064 KiB |
Judge Result
| Set Name | Sample | All | after_contest | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 350 / 350 | 0 / 0 | ||||||
| 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 |
| after_contest | after_contest_1.txt, after_contest_2.txt, after_contest_3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 0_sample_1.txt | AC | 0 ms | 1668 KiB |
| 0_sample_2.txt | AC | 0 ms | 1724 KiB |
| 0_sample_3.txt | AC | 0 ms | 1612 KiB |
| 1_1.txt | AC | 44 ms | 3644 KiB |
| 1_2.txt | AC | 43 ms | 3648 KiB |
| 1_3.txt | AC | 42 ms | 3692 KiB |
| 1_4.txt | AC | 42 ms | 3808 KiB |
| 1_5.txt | AC | 43 ms | 3632 KiB |
| 2_1.txt | AC | 50 ms | 4064 KiB |
| 2_2.txt | AC | 49 ms | 3880 KiB |
| 2_3.txt | AC | 49 ms | 3880 KiB |
| 2_4.txt | AC | 49 ms | 3856 KiB |
| 3_1.txt | AC | 49 ms | 4044 KiB |
| 3_2.txt | AC | 49 ms | 4044 KiB |
| 3_3.txt | AC | 48 ms | 4052 KiB |
| 3_4.txt | AC | 35 ms | 3760 KiB |
| 3_5.txt | AC | 0 ms | 1632 KiB |
| 3_6.txt | AC | 45 ms | 3948 KiB |
| 4_1.txt | AC | 19 ms | 3264 KiB |
| 4_2.txt | AC | 24 ms | 3308 KiB |
| 4_3.txt | AC | 0 ms | 1668 KiB |
| 4_4.txt | AC | 0 ms | 1748 KiB |
| after_contest_1.txt | AC | 0 ms | 1600 KiB |
| after_contest_2.txt | AC | 0 ms | 1640 KiB |
| after_contest_3.txt | AC | 0 ms | 1796 KiB |