Submission #3607627


Source Code Expand

#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x, y;
	cin >> x >> y;

	if(x <= y) {
		if(x >= 0 and y >= 0) {
			cout << y - x << endl;
			return 0;
		}
		if(x <= 0 and y >= 0) {
			if(abs(x) <= abs(y)) {
				ll rsl = 1 + y - abs(x);
				cout << rsl << endl;
				return 0;
			} else {
				ll rsl = abs(x) - y + 1;
				cout << rsl << endl;
				return 0;
			}
		}
		if(x <= 0 and y <= 0) {
			ll rsl = abs(x) - abs(y);
			cout << rsl << endl;
			return 0;
		}
	}

	if(x >= 0 and y >= 0) {
		ll rsl = 2 + x - y ;
		cout << rsl << endl;
	}

	if(x >= 0 and y <= 0) {
		if(abs(x) >= abs(y)) {
			ll rsl = 1 + x - abs(y);
			cout << rsl << endl;
			return 0;
		} else {
			ll rsl = 1 + abs(y) - x;
			cout << rsl << endl;
			return 0;
		}
	}

	if(x <= 0 and y <= 0) {
		ll rsl = 2 + abs(y) - abs(x);
		cout << rsl << endl;
		return 0;
	}

}

Submission Info

Submission Time
Task A - Simple Calculator
User tsutarou10
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1732 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 12
WA × 2
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt AC 1 ms 256 KB
1_03.txt WA 1 ms 256 KB
1_04.txt WA 1 ms 256 KB
1_05.txt AC 1 ms 256 KB
1_06.txt AC 1 ms 256 KB
1_07.txt AC 1 ms 256 KB
1_08.txt AC 1 ms 256 KB
1_09.txt AC 1 ms 256 KB
1_10.txt AC 1 ms 256 KB