Submission #1114152

#TimeUsernameProblemLanguageResultExecution timeMemory
1114152Dan4LifeSnowball (JOI21_ho_t2)C++17
33 / 100
2547 ms6908 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) #define int long long const int N = (int)2e5+10; const int LINF = (int)1e18; int n, q, a[N], w[N]; using ar2 = array<int,2>; ar2 xd[N]; ar2 f(int dis){ int a = 0, b = dis, mnB=dis, mxA = 0; for(int i = 0; i < q; i++){ if(!w[i]) continue; a+=w[i]; b+=w[i]; if(a>mnB) a=mnB; if(b<mxA) b=mxA; mxA = max(mxA, a); mnB = min(mnB, b); if(mxA>=mnB) break; } return {mxA,dis-mnB}; } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> q; a[0] = -LINF; a[n+1]=LINF; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 0; i < q; i++) cin >> w[i]; for(int i = 1; i <= n+1; i++) xd[i] = f(a[i]-a[i-1]); for(int i = 1; i <= n; i++) cout << xd[i][1]+xd[i+1][0] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...