Submission #202448

#TimeUsernameProblemLanguageResultExecution timeMemory
202448KastandaJust Long Neckties (JOI20_ho_t1)C++11
100 / 100
142 ms7112 KiB
// In The Name Of The Queen #include<bits/stdc++.h> #define x first #define y second using namespace std; const int N = 200005; int n, B[N], P[N], S[N], R[N]; pair < int , int > A[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n + 1; i ++) scanf("%d", &A[i].x), A[i].y = i; for (int i = 1; i <= n; i ++) scanf("%d", &B[i]); sort(A + 1, A + n + 2); sort(B + 1, B + n + 1); for (int i = 1; i <= n; i ++) P[i] = max(P[i - 1], A[i].x - B[i]); for (int i = n; i; i --) S[i] = max(S[i + 1], A[i + 1].x - B[i]); for (int i = 1; i <= n + 1; i ++) R[A[i].y] = max(P[i - 1], S[i]); for (int i = 1; i <= n + 1; i ++) printf("%d ", R[i]); return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
ho_t1.cpp:13:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i].x), A[i].y = i;
         ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
ho_t1.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &B[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...