이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long ll;
const ll INF = 1e9 + 7; //4e18
const ll N = 2005;
const ll MOD = 1e9 + 7;
#define vi vector <int>
#define vll vector <ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define endl '\n'
#define apaaja \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0); \
ll n, q, s, t;
vll v;
vll suhu;
int main(){
apaaja
cin >> n >> q >> s >> t;
for(ll i = 0; i <= n; i++){
ll z; cin >> z;
v.pb(z);
}
suhu.pb(0);
for(ll i = 1; i <= n; i++){
suhu.pb(suhu[i-1]);
if(v[i] > v[i-1]){
suhu[i] -= s * abs(v[i] - v[i-1]);
}
else {
suhu[i] += t * abs(v[i] - v[i-1]);
}
}
// for(ll i = 0; i <= n; i++){
// cout << suhu[i] << " ";
// }
// cout << endl;
// cout << suhu[n] << endl;
while(q--){
ll l, r, x;
cin >> l >> r >> x;
for(ll i = l; i <= r; i++){
v[i] += x;
}
// for(ll i = 0; i <= n; i++){
// cout << v[i] << " ";
// }cout << endl;
for(ll i = l; i <= n; i++){
suhu[i] = suhu[i-1];
if(v[i] > v[i-1]){
suhu[i] -= s * abs(v[i] - v[i-1]);
}
else {
suhu[i] += t * abs(v[i] - v[i-1]);
}
}
// for(ll i = 0; i <= n; i++){
// cout << suhu[i] << ".";
// }
// cout << endl;
cout << suhu[n] << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |