Submission #7091321
Source Code Expand
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { int Alice = 0; int Bob = 0; int N; ArrayList<Integer> cards = new ArrayList<Integer>(); Scanner scan = new Scanner(System.in); N = scan.nextInt(); for(int i = 0; i < N; i++) { cards.add(scan.nextInt()); } Collections.sort(cards, Collections.reverseOrder()); for(int i = 0; i < N; i+=2) { Alice += cards.get(i); } for(int i = 1; i < N; i+=2) { Bob += cards.get(i); } System.out.println(Alice - Bob); scan.close(); } }
Submission Info
Submission Time | |
---|---|
Task | B - Card Game for Two |
User | ctenq |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 634 Byte |
Status | AC |
Exec Time | 110 ms |
Memory | 22996 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 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 | 97 ms | 19028 KB |
in2.txt | AC | 93 ms | 21076 KB |
in3.txt | AC | 92 ms | 22612 KB |
in4.txt | AC | 91 ms | 19924 KB |
in5.txt | AC | 97 ms | 18644 KB |
in6.txt | AC | 98 ms | 21844 KB |
in7.txt | AC | 110 ms | 22612 KB |
in8.txt | AC | 110 ms | 20692 KB |
in9.txt | AC | 105 ms | 22996 KB |
sample_1.txt | AC | 93 ms | 21332 KB |
sample_2.txt | AC | 92 ms | 18644 KB |
sample_3.txt | AC | 91 ms | 21844 KB |