This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
using namespace std;
long long s, t;
long long oblicz(long long roznica)
{
if (roznica > 0)
return -s * roznica;
return -t * roznica;
}
int main()
{
ios::sync_with_stdio(0), cin.tie();
int n, q;
cin >> n >> q >> s >> t;
vector<int> liczby(n + 1);
for (int i = 0; i <= n; i++)
cin >> liczby[i];
vector<long long> roznice(n);
long long odp = 0;
for (int i = 0; i < n; i++)
{
roznice[i] = liczby[i + 1] - liczby[i];
odp += oblicz(roznice[i]);
}
while (q--)
{
int poczatek, koniec, zmiana;
cin >> poczatek >> koniec >> zmiana;
poczatek--;
odp -= oblicz(roznice[poczatek]);
roznice[poczatek] += zmiana;
odp += oblicz(roznice[poczatek]);
if (koniec < n)
{
odp -= oblicz(roznice[koniec]);
roznice[koniec] -= zmiana;
odp += oblicz(roznice[koniec]);
}
cout << odp << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |