Submission #1148905

#TimeUsernameProblemLanguageResultExecution timeMemory
1148905Shadow1Just Long Neckties (JOI20_ho_t1)C++20
100 / 100
67 ms8516 KiB
// Programmer: Shadow1 #include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using str = string; // yay python! #define i64 int64_t #define show(x) cerr << (#x) << " = " << (x) << '\n'; #define output_vector(v) for(auto &x : v){cout << x << ' ';}cout << '\n'; #define output_pairvector(v) for(auto &x : v){cout << x.first << " " << x.second << '\n';} #define read_vector(v) for(auto &x : v){cin >> x;} #define vt vector #define pq priority_queue #define pb push_back #define eb emplace_back #define pii pair<int,int> #define umap unordered_map #define uset unordered_set #define fir first #define sec second #define sz(x) ll(x.size()) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define int ll #define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end()); // // const int INF = 1e18; void solve() { int n; cin >> n; vector<pii> a(n+1); vector<int> b(n), ans(n+1); for(int i=0; i<=n; ++i) { cin >> a[i].fir; a[i].sec = i; } for(auto &B : b) cin >> B; sort(all(b)); sort(all(a)); int odd = 0; for(int i=0; i<n; ++i) odd = max(odd, max(a[i].fir-b[i], 0ll)); ans[a[n].sec] = odd; for(int i=n-1; i>=0; --i) { odd = max(odd, max(0ll, a[i+1].fir - b[i])); ans[a[i].sec] = odd; } output_vector(ans); } signed main() { // freopen("output.txt", "w", stdout); // freopen("input.txt", "r", stdin); ios::sync_with_stdio(false); cin.tie(NULL); int T = 1; // cin >> T; while(T--) solve(); return 0; } /* CHECK : 1. COMPARATOR FUNCTION MUST RETURN FALSE WHEN ARGUMENTS ARE EQUAL!!! 2. Overflow! Typecase int64_t on operations if varaibles are int 3. Check array bounds!!! 4. Check array indexing!!! 5. Edge cases. (N==1)!!! */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...