Submission #35107777


Source Code Expand

#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;

int main(){
	ll X, Y, Z;
	ll ans = 0;
	cin >> X >> Y >> Z;
	if (X*Y>0&&abs(Y)<abs(Z)&&abs(X)>abs(Y)&&Y*Z>0) {
		ans = -1;
	
	}
	else if ((X > 0 && Y < 0) || (X < 0 && Y>0)) {
		ans += abs(X);
	}
	else if (X * Y > 0 && abs(X) < abs(Y)) {
		ans+= abs(X);
	}
	else{
		ans += abs(Z);
		ans += abs(X - Z);
		
	}
	cout << ans << endl;


}

Submission Info

Submission Time
Task B - Hammer
User amaoto
Language C++ (GCC 9.2.1)
Score 200
Code Size 535 Byte
Status AC
Exec Time 8 ms
Memory 3604 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 27
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 8 ms 3600 KiB
random_02.txt AC 2 ms 3560 KiB
random_03.txt AC 2 ms 3416 KiB
random_04.txt AC 3 ms 3388 KiB
random_05.txt AC 1 ms 3500 KiB
random_06.txt AC 2 ms 3416 KiB
random_07.txt AC 2 ms 3528 KiB
random_08.txt AC 2 ms 3496 KiB
random_09.txt AC 2 ms 3504 KiB
random_10.txt AC 2 ms 3592 KiB
random_11.txt AC 2 ms 3540 KiB
random_12.txt AC 2 ms 3564 KiB
random_13.txt AC 2 ms 3380 KiB
random_14.txt AC 6 ms 3552 KiB
random_15.txt AC 2 ms 3596 KiB
random_16.txt AC 2 ms 3432 KiB
random_17.txt AC 2 ms 3604 KiB
random_18.txt AC 2 ms 3564 KiB
random_19.txt AC 3 ms 3416 KiB
random_20.txt AC 2 ms 3528 KiB
random_21.txt AC 2 ms 3416 KiB
random_22.txt AC 3 ms 3500 KiB
random_23.txt AC 1 ms 3552 KiB
random_24.txt AC 2 ms 3540 KiB
sample_01.txt AC 2 ms 3596 KiB
sample_02.txt AC 2 ms 3524 KiB
sample_03.txt AC 2 ms 3388 KiB