이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb push_back
#define mid(l, r) ((l)+(r))/2
#define len(a) (a).length()
#define sz(a) (a).size()
#define xx first
#define yy second
#define inf int(2e9)
#define ff(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i, a, b) for(int (i) = (a); (i) >= (b); --(i))
#define maxn 200005
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<class T>
void print(const T niz[], const int siz)
{
for(int i=0;i<siz;i++)
cout << niz[i] << " ";
cout << endl;
}
int n,q;
ll s,t;
ll niz[maxn];
ll dif[maxn];
ll res;
int main()
{
ios_base::sync_with_stdio(false);
cin >> n >> q >> s >> t;
ff(i,0,n)cin >> niz[i];
ff(i,0,n-1){
dif[i] = niz[i + 1] - niz[i];
if(dif[i] > 0)res -= dif[i]*s;
else res -= dif[i]*t;
}
while(q--){
int l,r;
ll x;
cin >> l >> r >> x;
if(dif[l-1] > 0)res += dif[l-1]*s;
else res += dif[l-1]*t;
dif[l-1] += x;
if(dif[l-1] > 0)res -= dif[l-1]*s;
else res -= dif[l-1]*t;
if(r != n){
if(dif[r] > 0)res += dif[r]*s;
else res += dif[r]*t;
dif[r] -= x;
if(dif[r] > 0)res -= dif[r]*s;
else res -= dif[r]*t;
}
cout << res << endl;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
foehn_phenomena.cpp:2:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/stack:200000000")
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |