| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1004651 | Trisanu_Das | Jobs (BOI24_jobs) | C++17 | 165 ms | 59096 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 314159;
int pr[300005];
bool vis[300005];
vector<int> adj[300005];
vector<pair<int,int> > op;
void dfs(int x, int prof, int maxProf, int loss) {
vis[x] = 1;
if(prof + pr[x] > maxProf) op.push_back({loss - maxProf, prof + pr[x] - maxProf});
for(auto i: adj[x]) dfs(i, prof + pr[x], max(maxProf, prof + pr[x]), min(loss, prof + pr[x]));
}
signed main() {
int n, s, ans = 0; cin >> n >> s;
for(int i = 1,p; i <= n; i++) {
cin >> pr[i] >> p;
adj[p].push_back(i);
}
for(int i = 1; i <= n; i++) if(!vis[i]) dfs(i, 0, 0, 0);
sort(op.begin(), op.end(), greater<pair<int, int> >());
for(int i = 0; i < op.size() && op[i].first + s >= 0; i++) s += op[i].second, ans += op[i].second;
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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
