Submission #791595

#TimeUsernameProblemLanguageResultExecution timeMemory
791595n3rm1nSnowball (JOI21_ho_t2)C++17
0 / 100
2 ms380 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const long long MAXN = 2005; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } long long n, q; long long a[MAXN], wind[MAXN]; long long moveleft[MAXN], moveright[MAXN]; void read() { cin >> n >> q; for (long long i = 1; i <= n; ++ i) cin >> a[i]; long long pos = 0; for (long long i = 1; i <= q; ++ i) { cin >> wind[i]; pos += wind[i]; moveleft[i] = min(pos, moveleft[i-1]); moveright[i] = max(pos, moveright[i-1]); } for (long long i = 1; i <= q; ++ i) { moveleft[i] *= -1; // cout << moveleft[i] << " " << moveright[i] << endl; } } long long ans[MAXN]; void solve() { for (long long i = 2; i <= n; ++ i) { for (long long j = 1; j <= q; ++ j) { if(a[i-1] + moveright[j] > a[i] - moveleft[j]) { // cout << "***" << endl; // cout << i-1 << " " << i << " " << j << endl; long long segment = a[i] - a[i-1]; long long to_first = 0, to_second = 0; if(wind[j] >= 0) { to_second = moveleft[j]; to_first = segment - to_second; } else { to_first = moveright[j]; to_second = segment - to_first; } //cout << to_first << " " << to_second << endl; ans[i-1] += to_first; ans[i] += to_second; break; } } } ans[1] += moveleft[q]; ans[n] += moveright[q]; for (long long i = 1; i <= n; ++ i) cout << ans[i] << " "; cout << endl; } int main() { speed(); read(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...