Submission #853320

#TimeUsernameProblemLanguageResultExecution timeMemory
853320iulia_morariuSnowball (JOI21_ho_t2)C++14
33 / 100
2522 ms2392 KiB
#include <bits/stdc++.h> using namespace std; struct punct{ long long int c; // coordonata long long int st; // cel mai din stanga colectat long long int dr; // cel mai din dreapta colectat long long int w; // the weight }; int main(){ cin.tie(0);ios::sync_with_stdio(0); //1. int n, q; //2. cin >> n >> q; punct v[n + 2]; //3. for(int i = 1; i <= n; i++){ cin >> v[i].c; v[i].st = v[i].c; v[i].dr = v[i].c; v[i].w = 0; } v[0].c = -1000000000000000000; v[0].st = -1000000000000000000; v[0].dr = -1000000000000000000; v[n + 1].c = 1000000000000000000; v[n + 1].st = 1000000000000000000; v[n + 1].dr = 1000000000000000000; cout << endl; for(int ii = 0; ii < q; ii++){ long long int x; cin >> x; //cout << "coord de inceput : "; //for(int i = 1; i <= n; i++) cout << v[i].c << " "; //cout << endl; for(int i = 1; i <= n; i++){ long long int l = min(v[i].c, v[i].c + x); long long int r = max(v[i].c, v[i].c + x); if(x < 0){ if(l < v[i].st){ //cout << " -- > Adaugam la pozitia " << i << " " << v[i].st - max(l, v[i - 1].dr) << endl; v[i].w += max(0ll, v[i].st - max(l, v[i - 1].dr)); v[i].st = l; } }else{ if(r > v[i].dr){ //cout << " -- > Adaugam la pozitia " << i << " " << min(r, v[i + 1].st) - v[i].dr << endl; v[i].w += max(0ll, min(r, v[i + 1].st) - v[i].dr); v[i].dr = r; } } v[i].c += x; } } for(int i = 1; i <= n; i++){ cout << v[i].w << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...