結果
問題 | No.131 マンハッタン距離 |
ユーザー |
|
提出日時 | 2015-12-05 11:57:42 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,967 bytes |
コンパイル時間 | 1,448 ms |
コンパイル使用メモリ | 160,464 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-14 14:23:22 |
合計ジャッジ時間 | 2,764 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i,n) for(int i=0;i<(n);++i)#define loop for(;;)#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;#define all(v) begin(v),end(v)#define pb push_back#define inf (1e9)#define eps (1e-9)using Integer = long long;using Real = long double;const Real PI = acosl(-1);using P = pair<int, int>;template<class S, class T> inlineostream& operator<<(ostream&os, pair<S,T> p) {return os << '(' << p.first << ", " << p.second << ')';}template<class T, class U> inlineostream& operator<<(ostream&os, tuple<T,U> t) {return os << '('<< get<0>(t) << ", "<< get<1>(t) << ')';}template<class S, class T, class U> inlineostream& operator<<(ostream&os, tuple<S,T,U> t) {return os << '('<< get<0>(t) << ", "<< get<1>(t) << ", "<< get<2>(t) << ')';}template<class T> inlineostream& operator<<(ostream&os, set<T> v) {os << "(set";for (T item: v) os << ' ' << item;os << ")";return os;}template<class T> inlineostream& operator<<(ostream&os, vector<T> v) {if (v.size() == 0) { return os << "(empty)"; }os << v[0];for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];return os;}template<class T> inlineistream& operator>>(istream&is, vector<T>&v) {rep (i, v.size()) is >> v[i];return is;}// ^ > v <int dx[] = { -1, 0, 1, 0 };int dy[] = { 0, 1, 0, -1 };using vi = vector<int>;using vvi = vector<vi>;using vd = vector<double>;using vvd = vector<vd>;using vb = vector<bool>;int main() {cin.tie(0);ios::sync_with_stdio(0);cout.setf(ios::fixed);cout.precision(10);random_device dev;mt19937 rand(dev());int x, y, d; cin >> x >> y >> d;if (d <= x and d <= y) {cout << (d+1) << endl;}else if (d <= x or d <= y) {cout << (min(x,y)+1) << endl;}else if ((x+y)<d) {cout << 0 << endl;}else {cout <<(x+y-d+1)<<endl;}return 0;}