Submission #936898

#TimeUsernameProblemLanguageResultExecution timeMemory
936898the_coding_poohSnowball (JOI21_ho_t2)C++14
33 / 100
625 ms2332 KiB
#include <bits/stdc++.h> #define uwu return 0; using namespace std; const int SIZE = 2e3 + 5; int N, Q; const long long INF = 3e18 + 5; long long L[SIZE], R[SIZE], W[SIZE], X[SIZE]; int main(){ cin >> N >> Q; L[N + 1] = INF; R[0] = -INF; for (int i = 1; i <= N;i++){ cin >> X[i]; L[i] = X[i]; R[i] = X[i]; W[i] = 0; } long long in_W; for (int i = 1; i <= Q;i++){ cin >> in_W; if(in_W >= 0){ for (int i = 1; i <= N; i++){ if(X[i] + in_W > R[i]){ if(L[i + 1] > X[i] + in_W){ W[i] += (X[i] + in_W - R[i]); R[i] = X[i] + in_W; } else{ W[i] += (L[i + 1] - R[i]); R[i] = L[i + 1]; } } X[i] += in_W; } } else{ for (int i = 1; i <= N; i++){ if(X[i] + in_W < L[i]){ if(R[i - 1] < X[i] + in_W){ W[i] += (L[i] - (X[i] + in_W)); L[i] = X[i] + in_W; } else{ W[i] += (L[i] - R[i - 1]); L[i] = R[i - 1]; } } X[i] += in_W; } } } for (int i = 1; i <= N;i++){ cout << W[i] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...