Submission #1307659

#TimeUsernameProblemLanguageResultExecution timeMemory
1307659naman123Snowball (JOI21_ho_t2)C++20
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; vector<ll> x(n); for (int i = 0; i < n; i++) cin >> x[i]; // Compute prefix sums of wind and track min/max ll cur = 0; ll mn = 0, mx = 0; for (int i = 0; i < q; i++) { ll w; cin >> w; cur += w; mn = min(mn, cur); mx = max(mx, cur); } // This tracks how far snow has been removed (in space, not time) ll rightmost_covered = LLONG_MIN / 4; vector<ll> weight(n, 0); // Process snowballs from west to east for (int i = 0; i < n; i++) { ll a = x[i] + mn; // leftmost point this snowball ever reaches ll b = x[i] + mx; // rightmost point this snowball ever reaches // Snow still exists only to the right of rightmost_covered ll start = max(a, rightmost_covered); if (start < b) { weight[i] = b - start; rightmost_covered = b; } } for (int i = 0; i < n; i++) { cout << weight[i] << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...