# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
347303 | CaroLinda | Just Long Neckties (JOI20_ho_t1) | C++14 | 416 ms | 18668 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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") ;
}
컴파일 시 표준 에러 (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... |