| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 95426 | choikiwon | 금 캐기 (IZhO14_divide) | C++17 | 59 ms | 10196 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 100010;
int N;
int X[MN], G[MN], E[MN];
ll esum[MN], gsum[MN];
vector<pair<ll, int> > ord1, ord2;
priority_queue<int> pq;
int main() {
scanf("%d", &N);
for(int i = 0; i < N; i++) {
scanf("%d %d %d", &X[i], &G[i], &E[i]);
}
for(int i = 0; i < N; i++) {
esum[i] = E[i];
gsum[i] = G[i];
if(i) {
esum[i] += esum[i - 1];
gsum[i] += gsum[i - 1];
}
}
for(int i = 0; i < N; i++) {
ord1.push_back({ (i? esum[i - 1] : 0) - X[i], i });
ord2.push_back({ esum[i] - X[i], i });
}
sort(ord1.begin(), ord1.end());
sort(ord2.begin(), ord2.end());
int pos = (int)ord2.size() - 1;
ll ans = 0;
for(int i = (int)ord1.size() - 1; i >= 0; i--) {
while(pos >= 0 && ord2[pos].first >= ord1[i].first) {
pq.push(ord2[pos--].second);
}
int x = ord1[i].second;
if(!pq.empty() && pq.top() >= x) {
ans = max(ans, gsum[ pq.top() ] - (x? gsum[x - 1] : 0));
}
}
printf("%lld", ans);
}
컴파일 시 표준 에러 (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... | ||||
