이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define db double
#define pb push_back
#define pf push_front
#define newl "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f first
#define s second
#define MOD 1000000007
using namespace std;
#pragma GCC diagnostic ignored "-Wunused-result"
void setIO(string name = "") {
ios_base::sync_with_stdio(0); cin.tie(0);
cout << fixed << setprecision(15);
if (name.size()) {
freopen((name+".in").c_str(), "r", stdin);
freopen((name+".out").c_str(), "w", stdout);
}
}
int main()
{
fast
//setIO("");
//freopen("filename.in", "r", stdin);
//freopen("filename.out", "w", stdout);
ll n; cin >> n;
vector <ll> nw(n + 1), init(n);
unordered_map <ll, ll> occ;
for (ll i = 0; i <= n; i++)
{
cin >> nw[i];
occ[i] = nw[i];
}
for (ll i = 0; i < n; i++) cin >> init[i];
sort(all(nw));
sort(all(init));
for (ll i = 0; i <= n; i++)
{
ll mx = 0;
for (ll x = 0, y = 0; x <= n; x++)
{
bool hap = 0;
if (occ[i] != nw[x] || hap)
{
ll nm = max((ll) 0, nw[x] - init[y]);
mx = max(mx, nm);
y++;
}
else hap = 1;
}
cout << mx << ' ';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |