結果
| 問題 | No.131 マンハッタン距離 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-04-04 11:13:39 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 499 bytes | 
| コンパイル時間 | 1,499 ms | 
| コンパイル使用メモリ | 165,416 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-03 07:05:39 | 
| 合計ジャッジ時間 | 2,444 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 24 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define llong long long
int main() {
    unsigned int x, y, d;
    cin >> x >> y >> d;
    bool left = y >= d;
    bool top = d > y && d <= x + y;
    bool right = d >= x && d <= x + y;
    bool bottom = d < x;
    if(left || top) {
        int x0, x1;
        x0 = left ? 0 : d - y;
        x1 = bottom ? d : x;
        cout << x1 - x0 + 1 << endl;
    } else {
        cout << 0 << endl;
    }
}
            
            
            
        