Submission #233707

# Submission time Handle Problem Language Result Execution time Memory
233707 2020-05-21T13:06:45 Z duality Just Long Neckties (JOI20_ho_t1) C++11
0 / 100
6 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 > 0) 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]);
                             ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 6 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 6 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 6 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -