# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
347303 | CaroLinda | Just Long Neckties (JOI20_ho_t1) | C++14 | 416 ms | 18668 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 ll long long
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x.size() )
const int MAXN = 2e5+10 ;
using namespace std ;
int N ;
int C[MAXN] , employees[MAXN] ;
pair<int,int> neckties[MAXN] ;
int main()
{
scanf("%d", &N) ;
for(int i = 1 ; i <= N+1 ; i++ )
{
scanf("%d", &neckties[i].first ) ;
neckties[i].second = i ;
}
sort(neckties+1, neckties + 2 + N ) ;
for(int i= 1 ; i <= N ; i++ ) scanf("%d", &employees[i] ) ;
sort(employees+1, employees + 1 + N ) ;
multiset< int > s ;
for(int i = 1 ; i <= N ; i++ ) s.insert( -max( neckties[i+1].first - employees[i] , 0 ) ) ;
for(int i=1 ; i <= N+1 ; i++ )
{
C[ neckties[i].second ] = -*s.begin() ;
if( i == N+1 ) break ;
auto it = s.find( -max(neckties[i+1].first - employees[i] , 0 ) ) ;
s.erase( it ) ;
s.insert( -max(neckties[i].first - employees[i] , 0 ) ) ;
}
for(int i = 1 ; i <= N+1 ; i++ ) printf("%d ", C[i] ) ;
printf("\n") ;
}
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... |