Submission #412982

#TimeUsernameProblemLanguageResultExecution timeMemory
412982ChaskaSnowball (JOI21_ho_t2)C++11
33 / 100
2586 ms12108 KiB
#include <bits/stdc++.h> #define pb push_back #define sp " " #define sl "\n" #define fi first #define se second #define mp make_pair #define sz(a) ((int)a.size()) #define all(a) a.begin(),a.end() #define rev(a) reverse(a.begin(),a.end()) #define PI 3.141592 #define fo(i,n) for (int i=0;i<n;i++) #define fofo(i,n,j,m) for (int i=0;i<n;i++) for (int j=0;j<m;j++) using namespace std; typedef long long ll; typedef pair<ll,ll> ii; typedef pair<int,ii> iii; typedef vector<int> vi; typedef vector<ii> vii; const int N=2e5+5,mod=1e9+7; ll n,q,a[N],w[N],acu,tam[N]; ll X[N],Y[N]; vector<pair<ll,ll>> group; // sortear por fi ll res[N]; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(); cin >> n >> q; fo(i,n) cin >> a[i]; fo(i,q) cin >> w[i]; ll x,y; x=y=0; fo(i,q) { acu += w[i]; if (acu < x) x = acu; if (acu > y) y = acu; tam[i] = abs(x) + abs(y); X[i] = abs(x); Y[i] = abs(y); } for (int i=0;i<n-1;i++) { ll p = a[i+1]-a[i]; // tam del seg // do the bin ? bool y = false; for (int j=0;j<q;j++) { if (tam[j]>=p) { if (j==0) { if (w[j]>=0) res[i] += p; else res[i+1] += p; } else { res[i] += Y[j-1]; res[i+1] += X[j-1]; p -= tam[j-1]; if (w[j]>=0) res[i] += p; else res[i+1] += p; } j = q+1; y = true; } } if (!y) { res[i] += Y[q-1]; res[i+1] += X[q-1]; } } res[0] += X[q-1]; res[n-1] += Y[q-1]; fo(i,n) cout << res[i] << "\n"; return 0; } // Recuerda limites // Recuerda casos especiales
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...