Submission #3237206
Source Code Expand
#[allow(unused_macros)]
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
let mut next = || { iter.next().unwrap() };
input_inner!{next, $($r)*}
};
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
let mut next = move || -> String{
bytes
.by_ref()
.map(|r|r.unwrap() as char)
.skip_while(|c|c.is_whitespace())
.take_while(|c|!c.is_whitespace())
.collect()
};
input_inner!{next, $($r)*}
};
}
#[allow(unused_macros)]
macro_rules! input_inner {
($next:expr) => {};
($next:expr, ) => {};
($next:expr, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($next, $t);
input_inner!{$next $($r)*}
};
}
#[allow(unused_macros)]
macro_rules! read_value {
($next:expr, ( $($t:tt),* )) => {
( $(read_value!($next, $t)),* )
};
($next:expr, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
};
($next:expr, chars) => {
read_value!($next, String).chars().collect::<Vec<char>>()
};
($next:expr, usize1) => {
read_value!($next, usize) - 1
};
($next:expr, $t:ty) => {
$next().parse::<$t>().expect("Parse error")
};
}
#[allow(unused_imports)]
use std::cmp;
fn main() {
input!{
n: usize,
a: [usize; n],
}
// println!("{:?}", a.iter().enumerate().max_by_key(|(_, &v)| v % 3).unwrap());
let mut a = a;
let mut alice = 0;
let mut bob = 0;
for i in 1..n+1 {
let mi = a.iter().enumerate().max_by_key(|&(_, v)| v).unwrap().0;
if i % 2 == 1 {
alice += a[mi];
} else {
bob += a[mi];
}
a[mi] = 0;
}
println!("{}", (alice - bob) as i32);
}
Submission Info
Submission Time |
|
Task |
A - Infinite Coins |
User |
arzk |
Language |
Rust (1.15.1) |
Score |
0 |
Code Size |
2063 Byte |
Status |
RE |
Exec Time |
9 ms |
Memory |
4352 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 100 |
Status |
|
|
Set Name |
Test Cases |
Sample |
s1.txt, s2.txt, s3.txt |
All |
in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, s1.txt, s2.txt, s3.txt |
Case Name |
Status |
Exec Time |
Memory |
in1.txt |
RE |
2 ms |
4352 KB |
in2.txt |
RE |
2 ms |
4352 KB |
in3.txt |
RE |
2 ms |
4352 KB |
in4.txt |
RE |
2 ms |
4352 KB |
in5.txt |
RE |
2 ms |
4352 KB |
in6.txt |
RE |
2 ms |
4352 KB |
s1.txt |
RE |
9 ms |
4352 KB |
s2.txt |
RE |
2 ms |
4352 KB |
s3.txt |
RE |
2 ms |
4352 KB |