Submission #37763837
Source Code Expand
//#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include <iomanip>
#include <complex>
#include <fstream>
#include <assert.h>
using namespace std;
#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } return false; }
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD = 998244353;// (int)1e9 + 7;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
multiset<int> vset;
vector<int> A(N);
rep(i, 0, N)
{
cin >> A[i];
vset.insert(A[i]);
}
rep(i, 0, N)
{
vset.erase(vset.find(A[i]));
int res = 0;
auto itr = vset.end();
itr--;
chmax(res, *itr - A[i]);
itr = vset.begin();
chmax(res, A[i] - *itr);
cout << res << endl;
vset.insert(A[i]);
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - 年齢の差 (Age Difference) |
| User | aquel |
| Language | C++ (GCC 9.2.1) |
| Score | 100 |
| Code Size | 1954 Byte |
| Status | AC |
| Exec Time | 777 ms |
| Memory | 16900 KiB |
Judge Result
| Set Name | Sample | Subtask1 | Subtask2 | Subtask3 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 25 / 25 | 30 / 30 | 45 / 45 | ||||||||
| Status |
|
|
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| Subtask1 | sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt |
| Subtask2 | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt |
| Subtask3 | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 03-01.txt, 03-02.txt, 03-03.txt, 03-04.txt, 03-05.txt, 03-06.txt, sample-01.txt, sample-02.txt, sample-03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01-01.txt | AC | 8 ms | 3448 KiB |
| 01-02.txt | AC | 2 ms | 3556 KiB |
| 01-03.txt | AC | 4 ms | 3608 KiB |
| 01-04.txt | AC | 2 ms | 3612 KiB |
| 01-05.txt | AC | 2 ms | 3592 KiB |
| 01-06.txt | AC | 3 ms | 3528 KiB |
| 01-07.txt | AC | 2 ms | 3588 KiB |
| 02-01.txt | AC | 6 ms | 3624 KiB |
| 02-02.txt | AC | 7 ms | 3572 KiB |
| 02-03.txt | AC | 7 ms | 3648 KiB |
| 02-04.txt | AC | 6 ms | 3588 KiB |
| 02-05.txt | AC | 2 ms | 3604 KiB |
| 02-06.txt | AC | 2 ms | 3584 KiB |
| 02-07.txt | AC | 3 ms | 3532 KiB |
| 02-08.txt | AC | 2 ms | 3572 KiB |
| 02-09.txt | AC | 4 ms | 3504 KiB |
| 02-10.txt | AC | 7 ms | 3656 KiB |
| 03-01.txt | AC | 525 ms | 16804 KiB |
| 03-02.txt | AC | 519 ms | 16748 KiB |
| 03-03.txt | AC | 547 ms | 16840 KiB |
| 03-04.txt | AC | 578 ms | 16900 KiB |
| 03-05.txt | AC | 72 ms | 4768 KiB |
| 03-06.txt | AC | 777 ms | 16804 KiB |
| sample-01.txt | AC | 5 ms | 3592 KiB |
| sample-02.txt | AC | 2 ms | 3540 KiB |
| sample-03.txt | AC | 2 ms | 3448 KiB |