Submission #4039154
Source Code Expand
#include <stdio.h> #include <stdlib.h> #include <math.h> #define rep(i, n) for(int i = 0; i < n; i++) #define in_arr(type, a, n) for(int i = 0; i < n; i++) scanf(type, &((a)[i])); int main(){ int n, *a; scanf("%d", &n); a = (int *)malloc(n); for(int i = 0; i < n; ++i){ scanf("%d", &a[i]); } for(int i = n - 1; i > 0; --i){ for(int j = i; j < n; ++j){ if(a[j] > a[j - 1]){ int tmp = a[j]; a[j] = a[j - 1]; a[j - 1] = tmp; } } } int alice = 0, bob = 0; for(int i = 0; i < n; i += 2){ alice += a[i]; } for(int i = 1; i < n; i += 2){ bob += a[i]; } printf("%d\n", alice - bob); free(a); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Card Game for Two |
User | stmtk |
Language | C (GCC 5.4.1) |
Score | 0 |
Code Size | 804 Byte |
Status | RE |
Exec Time | 437 ms |
Memory | 128 KB |
Compile Error
./Main.c: In function ‘main’: ./Main.c:10:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.c:13:9: 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 | 0 / 200 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_1.txt, sample_2.txt, sample_3.txt |
All | in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample_1.txt, sample_2.txt, sample_3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 1 ms | 128 KB |
in2.txt | AC | 1 ms | 128 KB |
in3.txt | AC | 1 ms | 128 KB |
in4.txt | AC | 1 ms | 128 KB |
in5.txt | RE | 437 ms | 128 KB |
in6.txt | RE | 97 ms | 128 KB |
in7.txt | RE | 98 ms | 128 KB |
in8.txt | RE | 98 ms | 128 KB |
in9.txt | RE | 99 ms | 128 KB |
sample_1.txt | AC | 1 ms | 128 KB |
sample_2.txt | AC | 1 ms | 128 KB |
sample_3.txt | AC | 1 ms | 128 KB |