Submission #201033

#TimeUsernameProblemLanguageResultExecution timeMemory
201033HellAngelJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
193 ms7544 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 200007; int n, b[maxn], IT[4 * maxn], ans[maxn]; pair<int, int> a[maxn]; void Update(int id, int l, int r, int pos, int val) { if(l == r) { IT[id] = val; return; } int mid = l + r >> 1; if(pos <= mid) Update(id * 2, l, mid, pos, val); else Update(id * 2 + 1, mid + 1, r, pos, val); IT[id] = max(IT[id * 2], IT[id * 2 + 1]); } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin); cin >> n; for(int i = 1; i <= n + 1; i++) { cin >> a[i].first; a[i].second = i; } sort(a + 1, a + n + 2); for(int i = 1; i <= n; i++) { cin >> b[i]; } sort(b + 1, b + n + 1); for(int i = 1; i <= n; i++) Update(1, 1, n, i, a[i + 1].first - b[i]); ans[a[1].second] = IT[1]; for(int i = 2; i <= n + 1; i++) { Update(1, 1, n, i - 1, a[i - 1].first - b[i - 1]); ans[a[i].second] = IT[1]; } for(int i = 1; i <= n + 1; i++) { cout << max(ans[i], 0) << ' '; } }

Compilation message (stderr)

ho_t1.cpp: In function 'void Update(int, int, int, int, int)':
ho_t1.cpp:16:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
ho_t1.cpp: In function 'int32_t main()':
ho_t1.cpp:27:39: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
                                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...