| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 503249 | blue | 금 캐기 (IZhO14_divide) | C++17 | 39 ms | 8864 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const ll INF = 1'000'000'000'000'000'000LL;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
ll x[1+N], g[1+N], d[1+N];
d[0] = 0;
g[0] = 0;
for(int i = 1; i <= N; i++)
{
cin >> x[i] >> g[i] >> d[i];
d[i] += d[i-1];
g[i] += g[i-1];
}
vector<pair<ll, ll> > A, B;
A.push_back({-INF, -INF});
B.push_back({-INF, -INF});
for(int i = 1; i <= N; i++)
{
A.push_back({d[i] - x[i], g[i]});
B.push_back({d[i-1] - x[i], - g[i-1]});
// cerr << i << " : " << d[i] - x[i] << "," << g[i] << " " << d[i-1]-x[i] << "," << -g[i-1] << '\n';
}
ll ans = 0;
sort(A.begin(), A.end());
sort(B.begin(), B.end());
ll sa = -INF, sb = -INF;
int a = 0, b = 0;
for(a = 1; a <= N; a++)
{
// sa = max(sa, A[a].second);
while(b+1 <= N && B[b+1].first <= A[a].first)
{
b++;
sb = max(sb, B[b].second);
}
ans = max(ans, A[a].second+sb);
}
cout << ans << '\n';
}
컴파일 시 표준 에러 (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... | ||||
