結果

問題 No.131 マンハッタン距離
ユーザー le_panda_noir
提出日時 2019-10-14 15:19:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 356 bytes
コンパイル時間 557 ms
コンパイル使用メモリ 65,408 KB
最終ジャッジ日時 2025-01-07 22:01:52
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
#define out(v) cout<<v<<"\n"

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

  if (d <= min(x, y)) {
    out(d+1);
  } else if (min(x, y) <= d && d <= max(x, y)) {
    out(min(x, y)+1);
  } else if (max(x, y) <= d) {
    out(max(0, x + y - d + 1));
  }

  return 0;
}
0