답안 #233706

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233706 2020-05-21T13:05:53 Z duality Just Long Neckties (JOI20_ho_t1) C++11
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long int LLI;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

pii A[200001];
int B[200000],C[200001],ans[200001];
int main() {
    int i;
    int N;
    scanf("%d",&N);
    for (i = 0; i <= N; i++) scanf("%d",&A[i].first),A[i].second = i;
    for (i = 0; i < N; i++) scanf("%d",&B[i]);
    sort(A,A+N+1),sort(B,B+N);

    int m = 0;
    for (i = 0; i <= N; i++) {
        C[i] = max(C[i],m);
        if (i < N) m = max(m,abs(A[i].first-B[i]));
    }
    m = 0;
    for (i = N; i >= 0; i--) {
        C[i] = max(C[i],m);
        if (i < N) m = max(m,abs(A[i].first-B[i-1]));
    }
    for (i = 0; i <= N; i++) ans[A[i].second] = C[i];
    for (i = 0; i <= N; i++) printf("%d ",ans[i]);
    printf("\n");

    return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
ho_t1.cpp:16:53: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; i <= N; i++) scanf("%d",&A[i].first),A[i].second = i;
                              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
ho_t1.cpp:17:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; i < N; i++) scanf("%d",&B[i]);
                             ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -