Submission #1041132
Source Code Expand
#include <bits/stdc++.h> #define SZ(x) ((int) (x).size()) using namespace std; typedef long long i64; int64_t mabs(int64_t x) { return x < 0 ? -x: x; } int main() { #ifdef LOCAL_RUN freopen("task.in", "r", stdin); freopen("task.out", "w", stdout); //freopen("task.err", "w", stderr); #endif // ONLINE_JUDGE ios::sync_with_stdio(false); cin.tie(0); int64_t x, y; cin >> x >> y; if (x == y) { cout << "0\n"; } else { int64_t ans = 0; if (mabs(x + 1 - y) > mabs(x - y)) { x *= -1; ans++; } ans += mabs(mabs(x) - mabs(y)); x += mabs(x - y); if (x != y) { ans++; } cout << ans << "\n"; } }
Submission Info
Submission Time | |
---|---|
Task | A - Simple Calculator |
User | AndreiNet |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 786 Byte |
Status | WA |
Exec Time | 3 ms |
Memory | 384 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
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 | 3 ms | 256 KB |
0_01.txt | AC | 3 ms | 256 KB |
0_02.txt | AC | 3 ms | 256 KB |
1_00.txt | WA | 3 ms | 256 KB |
1_01.txt | AC | 3 ms | 256 KB |
1_02.txt | WA | 3 ms | 256 KB |
1_03.txt | AC | 3 ms | 256 KB |
1_04.txt | AC | 3 ms | 256 KB |
1_05.txt | WA | 3 ms | 256 KB |
1_06.txt | WA | 3 ms | 256 KB |
1_07.txt | AC | 3 ms | 256 KB |
1_08.txt | WA | 3 ms | 384 KB |
1_09.txt | WA | 3 ms | 256 KB |
1_10.txt | AC | 3 ms | 256 KB |