이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
i64 N, Q, S, T;
cin >> N >> Q >> S >> T;
i64 pocz = 0, pop;
cin >> pop;
vector<i64> wys(N);
for (i64 i = 0; i < N; i++)
{
i64 x;
cin >> x;
wys[i] = x - pop;
pop = x;
if (wys[i] < 0)
pocz += wys[i] * -1 * T;
else
pocz -= wys[i] * S;
}
//cout << pocz << "\n";
for (i64 i = 0; i < Q; i++)
{
i64 L, R, X;
cin >> L >> R >> X;
if (wys[L - 1] >= 0 && X > 0)
{
pocz -= X * S;
//cout << -1 * X * S << " :\n";
}
else if (wys[L - 1] <= 0 && X < 0)
{
pocz += X * T;
//cout << X * T << " ::\n";
}
else if (wys[L - 1] >= 0 && X < 0)
{
pocz += min(wys[L - 1], X * -1) * S;
pocz += max(X * -1 - wys[L - 1], (i64)0) * T;
//cout << min(wys[L - 1], X * -1) * S + max(X * -1 - wys[L - 1], (i64)0) * T << " :::\n";
}
else
{
pocz -= min(wys[L - 1] * -1, X) * T;
pocz -= max(X + wys[L - 1], (i64)0) * S;
//cout << -1 * min(wys[L - 1] * -1, X) * T << " : " << -1 * max(X + wys[L - 1], (i64)0) * S << " ::::\n";
//cout << " :::::: " << wys[L - 1] * -1 << " :::: " << X << "\n";
}
wys[L - 1] += X;
if (R < N)
{
if (wys[R] >= 0 && X < 0)
{
pocz += X * S;
//cout << -1 * X * S << " -\n";
}
else if (wys[R] <= 0 && X > 0)
{
pocz += X * T;
//cout << X * T << " --\n";
}
else if (wys[R] >= 0 && X > 0)
{
pocz += min(wys[R], X) * S;
pocz += max(X - wys[R], (i64)0) * T;
//cout << min(wys[R], X) * S + max(X - wys[R], (i64)0) * T << " ---\n";
}
else
{
pocz -= min(wys[R] * -1, X * -1) * T;
pocz -= max(X * -1 + wys[R], (i64)0) * S;
//cout << -1 * min(wys[R] * -1, X * -1) * T - max(X * -1 + wys[R], (i64)0) * S << " ----\n";
}
wys[R] -= X;
}
cout << pocz << "\n";
/* cout << "\n";
for (i64 k = 0; k < wys.size(); k++)
{
cout << wys[k] << " ";
}
cout << "\n\n";*/
/*for (i64 k = 0; k < wys.size(); k++)
{
cout << wys[k] << " ";
}
cout << "\n";*/
}
return 0;
}
/*
#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;
int main()
{
//ios_base::sync_with_stdio(0);
//cin.tie(0);
i64 N, Q, S, T;
cin >> N >> Q >> S >> T;
i64 pocz = 0, pop;
cin >> pop;
vector<i64> wys(N);
for (i64 i = 0; i < N; i++)
{
i64 x;
cin >> x;
wys[i] = x - pop;
pop = x;
if (wys[i] < 0)
pocz += wys[i] * -1 * T;
else
pocz -= wys[i] * S;
}
cout << pocz << "\n";
for (i64 i = 0; i < Q; i++)
{
i64 L, R, X;
cin >> L >> R >> X;
if (wys[L - 1] >= 0 && X > 0)
{
pocz -= X * S;
cout << X * S << " :\n";
}
else if (wys[L - 1] <= 0 && X < 0)
{
pocz += X * T;
cout << X * T << " ::\n";
}
else if (wys[L - 1] >= 0 && X < 0)
{
pocz += min(wys[L - 1], X * -1) * S;
pocz += max(X * -1 - wys[L - 1], (i64)0) * T;
}
else
{
pocz -= min(wys[L - 1] * -1, X) * T;
pocz -= max(X + wys[L - 1], (i64)0) * S;
}
wys[L - 1] += X;
if (R < N)
{
if (wys[R] >= 0 && X < 0)
{
pocz -= X * S;
cout << X * S << " -\n";
}
else if (wys[R] <= 0 && X > 0)
{
pocz += X * T;
cout << X * T << " --\n";
}
else if (wys[R] >= 0 && X > 0)
{
pocz += min(wys[R], X) * S;
pocz += max(X - wys[R], (i64)0) * T;
}
else
{
pocz -= min(wys[R] * -1, X) * T;
pocz -= max(X + wys[R], (i64)0) * S;
}
wys[R] += X;
}
cout << pocz << "\n";
/*for (i64 k = 0; k < wys.size(); k++)
{
cout << wys[k] << " ";
}
cout << "\n";
}
return 0;
}
*/
컴파일 시 표준 에러 (stderr) 메시지
foehn_phenomena.cpp:197:9: warning: "/*" within comment [-Wcomment]
197 | /*for (i64 k = 0; k < wys.size(); k++)
|
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |