Submission #256950

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
2569502020-08-03 12:51:32akatJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
118 ms10104 KiB
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, i;
pair<int,int> p[N];
cin>>n;
for(i = 0; i < n + 1; i++)
{
cin>>p[i].first;
p[i].second = i;
}
int b[N];
for(i = 0; i < n; i++)
cin>>b[i];
sort(p, p + n + 1);
sort(b, b + n);
int m[N];
m[0] = max(p[0].first - b[0], 0);
for(i = 1; i < n; i++)
m[i] = max(m[i-1], p[i].first - b[i]);
int ans[N], cm = 0;
for(i = n; i > 0; i--)
{
ans[p[i].second] = max(m[i-1], cm);
cm = max(cm, p[i].first - b[i-1]);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...