| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1286218 | ilovewaguri | Foehn Phenomena (JOI17_foehn_phenomena) | C++20 | 13 ms | 1012 KiB |
#include<bits/stdc++.h>
using namespace std;
#define NAME "TEST"
#define nl '\n'
#define allofa(x,sz) x,x+sz+1
#define allof(x) x.begin(),x.end()
#define mset(x,val) memset(x,val,sizeof(x))
template<class X,class Y> bool minimize(X &a, Y b){if(a>b){a=b;return true;}return false;};
template<class X,class Y> bool maximize(X &a, Y b){if(a<b){a=b;return true;}return false;};
typedef long long ll;
const ll mod = (long long)1e9+7;
const ll LINF = (long long)1e18;
const int INF = (int)1e9;
const int MAXN = (int)2e5+5;
int a[MAXN];
int n,q,s,t;
void ccps() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if(fopen(NAME".inp","r")) {
freopen(NAME".inp","r",stdin);
freopen(NAME".out","w",stdout);
}
}
namespace sub1 {
const int N = 2010;
ll diff[N],pref[N];
bool check() {
return n<=2000 and q<=2000;
}
void sol() {
vector<int> v;
for (int i = 0; i<=n; i++) {
v.push_back(a[i]);
}
reverse(allof(v));
for (int i = 0; i<n; i++) {
diff[i]=v[i+1]-v[i];
}
while(q--) {
int l,r,x; cin >> l >> r >> x;
l=n-l;
r=n-r;
if(l>r) swap(l,r);
l--;r--;
diff[l]+=x;
diff[r+1]-=x;
ll res = 0;
for (int i = 0; i<n; i++) {
if(diff[i]>0) res+=1LL*t*diff[i];
else res+=1LL*s*diff[i];
}
cout << res << nl;
}
}
}
signed main() {
ccps();
cin >> n >> q >> s >> t;
for (int i = 0; i<=n; i++) {
cin >> a[i];
}
if(sub1::check()) sub1::sol();
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
