Submission #5163895


Source Code Expand

Copy
void main() {
	auto N = ri;
	auto A = readAs!(long[]);
	ulong cnt = A.count!(i => i < 0);
	ulong res = A.map!(i => i.abs).sum;
	if(cnt % 2) res -= A.map!(i => i.abs).reduce!min * 2;
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Submission Info

Submission Time
Task D - Flipping Signs
User private_yusuke
Language D (DMD64 v2.070.1)
Score 400
Code Size 1228 Byte
Status AC
Exec Time 28 ms
Memory 4476 KB

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
AC × 23
AC × 3
Set Name Test Cases
All sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18, testcase_19, testcase_20
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 1 ms 256 KB
testcase_01 AC 18 ms 4092 KB
testcase_02 AC 8 ms 2940 KB
testcase_03 AC 27 ms 3964 KB
testcase_04 AC 9 ms 1584 KB
testcase_05 AC 2 ms 508 KB
testcase_06 AC 25 ms 3752 KB
testcase_07 AC 16 ms 3900 KB
testcase_08 AC 20 ms 3736 KB
testcase_09 AC 18 ms 4064 KB
testcase_10 AC 26 ms 4092 KB
testcase_11 AC 15 ms 3544 KB
testcase_12 AC 11 ms 1664 KB
testcase_13 AC 28 ms 3944 KB
testcase_14 AC 28 ms 4200 KB
testcase_15 AC 25 ms 4404 KB
testcase_16 AC 27 ms 4476 KB
testcase_17 AC 27 ms 3964 KB
testcase_18 AC 11 ms 3580 KB
testcase_19 AC 1 ms 256 KB
testcase_20 AC 28 ms 3964 KB