# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
228487 | Ruxandra985 | Just Long Neckties (JOI20_ho_t1) | C++14 | 161 ms | 13276 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>
#define DIMN 200010
using namespace std;
pair <int,int> v[DIMN];
int w[DIMN];
priority_queue <pair <int,int> > h;
int val[DIMN] , sol[DIMN];
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int n , i , x , idx;
fscanf (fin,"%d",&n);
for (i = 1 ; i <= n + 1 ; i++){
fscanf (fin,"%d",&v[i].first);
v[i].second = i;
}
for (i = 1 ; i <= n ; i++){
fscanf (fin,"%d",&w[i]);
}
sort (w + 1 , w + n + 1);
sort (v + 1 , v + n + 2);
/// o sa cuplezi al i lea din w cu al i + 1 lea din v
for (i = 1 ; i <= n ; i++){
h.push(make_pair(max(0 , v[i].first - w[i]) , i));
val[i] = max(0 , v[i].first - w[i]);
}
/// asta ar fi solutia pt cand elimini v[1].second
sol[v[n+1].second] = h.top().first;
for (i = n ; i ; i--){
val[i] = max(0 , v[i + 1].first - w[i]);
h.push(make_pair(val[i] , i));
/// pe v[i + 1].second il stergi
x = h.top().first;
idx = h.top().second;
while (val[idx] != x){
h.pop();
x = h.top().first;
idx = h.top().second;
}
sol[v[i].second] = h.top().first;
}
for (i = 1 ; i <= n + 1 ; i++)
fprintf (fout,"%d " , sol[i] );
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... |