# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
599057 | jmyszka2007 | Snowball (JOI21_ho_t2) | C++17 | 133 ms | 12916 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
constexpr int MAXN = 2 * 1e5;
typedef long long ll;
ll s[MAXN + 10];
ll mx[MAXN + 10];
ll mn[MAXN + 10];
ll tab[MAXN + 10];
ll w[MAXN + 10];
ll res[MAXN + 10];
int bs(int l, int r, ll x) {
while(l < r) {
int mid = (l + r + 1) / 2;
if((mx[mid] - mn[mid]) <= x) {
l = mid;
}
else {
r = mid - 1;
}
}
return l;
}
int main() {
int n, t;
scanf("%d%d", &n, &t);
for(int i = 1; i <= n; i++) {
scanf("%lld", &tab[i]);
}
for(int i = 1; i <= t; i++) {
scanf("%lld", &w[i]);
s[i] = s[i - 1] + w[i];
mx[i] = max(mx[i - 1], s[i]);
mn[i] = min(mn[i - 1], s[i]);
}
for(int i = 1; i < n; i++) {
ll d = tab[i + 1] - tab[i];
int m = bs(0, t, d);
res[i] += mx[m];
res[i + 1] += mn[m] * -1;
if(m == t) {
continue;
}
if(w[m + 1] >= 0) {
res[i] += (d - mx[m] + mn[m]);
}
else {
res[i + 1] += (d - mx[m] + mn[m]);
}
}
res[1] += mn[t] * -1;
res[n] += mx[t];
for(int i = 1; i <= n; i++) {
printf("%lld ", res[i]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |