제출 #202042

#제출 시각아이디문제언어결과실행 시간메모리
202042JustInCaseJust Long Neckties (JOI20_ho_t1)C++17
0 / 100
5 ms376 KiB
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int32_t n; std::cin >> n; std::vector< int32_t > a(n + 1); for(int32_t i = 0; i < n + 1; i++) { std::cin >> a[i]; } std::vector< int32_t > b(n); for(int32_t i = 0; i < n; i++) { std::cin >> b[i]; } std::sort(a.begin(), a.end()); std::sort(b.begin(), b.end()); std::vector< int32_t > prefMax(n), suffMax(n); for(int32_t i = 0; i < n; i++) { if(i != 0) { prefMax[i] = prefMax[i - 1]; } else { prefMax[i] = 0; } prefMax[i] = std::max(prefMax[i], a[i] - b[i]); } for(int32_t i = n - 2; i >= 0; i--) { if(i != n - 2) { suffMax[i] = suffMax[i + 1]; } else { suffMax[i] = 0; } suffMax[i] = std::max(suffMax[i], a[i + 1] - b[i]); } std::cout << suffMax[0] << " "; for(int32_t i = 0; i < n - 1; i++) { std::cout << std::max(prefMax[i], suffMax[i + 1]) << " "; } std::cout << prefMax[n - 1] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...