Submission #201407

#TimeUsernameProblemLanguageResultExecution timeMemory
201407karmaJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
120 ms6192 KiB
#include <bits/stdc++.h> #define pb emplace_back #define ll long long #define fi first #define se second #define mp make_pair //#define int int64_t using namespace std; const int N = int(2e5) + 5; typedef pair<int, int> pii; int ans[N], b[N], n, suf[N], cur; pii a[N]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define Task "test" if(fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } cin >> n; ++n; for(int i = 1; i <= n; ++i) cin >> a[i].fi, a[i].se = i; for(int i = 1; i < n; ++i) cin >> b[i]; sort(a + 1, a + n + 1); sort(b + 1, b + n); for(int i = n, j = n - 1; i > 1; --i, --j) { suf[i] = max(suf[i + 1], max(a[i].fi - b[j], 0)); } cur = 0; for(int i = 1; i <= n; ++i) { ans[a[i].se] = max(cur, suf[i + 1]); cur = max(cur, max(a[i].fi - b[i], 0)); } for(int i = 1; i <= n; ++i) cout << ans[i] << ' '; }

Compilation message (stderr)

ho_t1.cpp: In function 'int32_t main()':
ho_t1.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".inp", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...