Submission #3809486
Source Code Expand
#include <stdio.h> int main() { int N; scanf("%d", &N); int A[N]; int i, j; for (i = 0; i < N; i++) { scanf("%d", &A[i]); } int former=0; for (i = 0; i < N; i++) { for (j = i+1; j < N; j++) { if (A[i] > A[j]) { int tmp; tmp = A[i]; A[i] = A[j]; A[j] = tmp; } } } // for (i = 0; i < N; i++) { // printf("%d ", A[i]); // } // printf("\n"); for (i = N-1; i >= 0; i--) { if ((N-1) % 2 == 0) {//N-1 is even number if (i % 2 == 0) { former += A[i]; } } else {//N-1 is odd number if (i % 2 == 1) { former += A[i]; } } } printf("%d\n", former); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - カードと兄妹 |
User | pennywise |
Language | C (GCC 5.4.1) |
Score | 100 |
Code Size | 660 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 128 KB |
Compile Error
./Main.c: In function ‘main’: ./Main.c:6:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.c:10:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &A[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt |
All | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 128 KB |
01-02.txt | AC | 1 ms | 128 KB |
01-03.txt | AC | 1 ms | 128 KB |
01-04.txt | AC | 1 ms | 128 KB |
01-05.txt | AC | 1 ms | 128 KB |
01-06.txt | AC | 1 ms | 128 KB |
01-07.txt | AC | 2 ms | 128 KB |
01-08.txt | AC | 2 ms | 128 KB |
01-09.txt | AC | 1 ms | 128 KB |
01-10.txt | AC | 1 ms | 128 KB |
01-11.txt | AC | 1 ms | 128 KB |
sample-01.txt | AC | 1 ms | 128 KB |
sample-02.txt | AC | 1 ms | 128 KB |