Submission #1041493


Source Code Expand

#include<bits/stdc++.h>
using namespace std;

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b;
    cin>>a>>b;

    int ans=LLONG_MAX;

    for(int i=-1;i<=1;i+=2){
        for(int j=-1;j<=1;j+=2){
            int aa=a*i;
            int bb=b*j;
            if(aa>bb)continue;
            chmin(ans,bb-aa+(i==-1)+(j==-1));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task A - Simple Calculator
User latte0119
Language C++14 (GCC 5.4.1)
Score 300
Code Size 892 Byte
Status AC
Exec Time 3 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 14
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 2 ms 256 KB
1_00.txt AC 2 ms 256 KB
1_01.txt AC 2 ms 256 KB
1_02.txt AC 3 ms 256 KB
1_03.txt AC 2 ms 256 KB
1_04.txt AC 3 ms 256 KB
1_05.txt AC 3 ms 256 KB
1_06.txt AC 2 ms 256 KB
1_07.txt AC 3 ms 256 KB
1_08.txt AC 3 ms 256 KB
1_09.txt AC 3 ms 256 KB
1_10.txt AC 2 ms 256 KB