結果

問題 No.716 距離
ユーザー private-dev-acctprivate-dev-acct
提出日時 2021-09-25 22:37:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,609 bytes
コンパイル時間 2,261 ms
コンパイル使用メモリ 203,244 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-19 02:45:25
合計ジャッジ時間 4,500 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#define endl "\n"
#define rep(i,s,l) for(int i=s;i<l;i++)
#define rev_rep(i,l,s) for(int i=l;i>=s;i--)
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() );

using ll = long long; 
using ld = long double;
using P = pair<ll, ll>; 
using VP = vector<P>;
using VI = vector<int>; 
using VLL = vector<ll>; 
using VS = vector<string>; 

const int INF = 2147483647;
const ll LINF = 1152921504606846976;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll p, ll q) { while (q) { ll t = p % q; p = q; q = t; } return p; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll fast_mod(ll x, ll y) { if (x >= y) { return x % y; } else if (x < 0) { return (x % y + y) % y; } else { return x; } }

signed main()
{
	const streamsize PRECISION_SIZE = 15;
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	std::cout << std::fixed << std::setprecision(PRECISION_SIZE);
	
	ll min_dist{ LINF }, max_dist{ -LINF };

	int N; cin >> N;
	VLL A(N);
	rep(i, 0, N)cin >> A[i];

	rep(i, 0, N-1) {
		rep(j, i + 1, N) {
			chmin(min_dist, abs(A[i] - A[j]));
			chmax(max_dist, abs(A[i] - A[j]));
		}
	}

	cout << min_dist << endl;
	cout << max_dist << endl;


	return EXIT_SUCCESS;
}
0