結果
| 問題 | No.131 マンハッタン距離 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-09-22 14:10:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 590 bytes |
| 記録 | |
| コンパイル時間 | 441 ms |
| コンパイル使用メモリ | 58,480 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 08:37:12 |
| 合計ジャッジ時間 | 1,368 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <iostream>
using namespace std;
#include <cstdio>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double lb;
/* ここからが本編 */
int main(void)
{
int i,j,k;
int x,y,d;
long ans;
cin >> x >> y >> d;
if(x < y) swap(x,y);
if(d > x + y) ans = 0;
else if(x >= d && y >= d ) ans = d + 1;
else {
ans = d+1;
if(x < d) ans -= d-x;
if(y < d) ans -= d-y;
}
cout << ans << endl;
return 0;
}