# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1114641 | AdamGS | Just Long Neckties (JOI20_ho_t1) | C++17 | 297 ms | 17992 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;
int main()
{
//ios_base::sync_with_stdio(0);
//cin.tie(0);
i64 N;
cin >> N;
vector<pair<i64, i64>> tie(N + 1);
for (i64 i = 0; i <= N; i++)
{
cin >> tie[i].first;
tie[i].second = i;
}
sort(tie.begin(), tie.end());
vector<i64> emp(N);
for (i64 i = 0; i < N; i++)
{
cin >> emp[i];
}
sort(emp.begin(), emp.end());
multiset<i64> akt;
vector<i64> wynik(N + 1);
for (i64 i = 1; i <= N; i++)
{
akt.insert(max(tie[i].first - emp[i - 1], (i64)0));
}
auto it = akt.end(); it--;
wynik[tie[0].second] = *it;
for (i64 i = 1; i <= N; i++)
{
auto it = akt.find(max((i64)0, tie[i].first - emp[i - 1]));
akt.erase(it);
akt.insert(max((i64)0, tie[i - 1].first - emp[i - 1]));
auto it2 = akt.end(); it2--;
wynik[tie[i].second] = *it2;
}
for (i64 i = 0; i < wynik.size(); i++)
{
cout << wynik[i] << ' ';
}
cout << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |