Submission #763002

#TimeUsernameProblemLanguageResultExecution timeMemory
763002vjudge1Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
109 ms9972 KiB
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 200'000;
pair<int, int> A[MAXN+1];
int B[MAXN];
int N;
int main()
{
    scanf("%d", &N);
    for(int i=0; i<N+1; ++i)
    {
        scanf("%d", &A[i].first);
        A[i].second = i;
    }
    for(int i=0; i<N; ++i) scanf("%d", B+i);
    sort(A, A+N+1); sort(B, B+N);
    vector<int> p(1), q(1);
    for(int i=0; i<N; ++i)
        p.push_back(max(p.back(),A[i].first-B[i]));
    for(int i=N-1; i>=0; --i)
        q.push_back(max(q.back(),A[i+1].first-B[i]));
    reverse(q.begin(), q.end());
    vector<int> ans(N+1);
    for(int i=0; i<=N; ++i)
        ans[A[i].second] = max(p[i], q[i]);
    for(int i=0; i<=N; ++i) printf("%d ", ans[i]);
    puts("");
}

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
ho_t1.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d", &A[i].first);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
ho_t1.cpp:16:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     for(int i=0; i<N; ++i) scanf("%d", B+i);
      |                            ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...