# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1183925 | lance0 | 친구 (IOI14_friend) | C++20 | 0 ms | 328 KiB |
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
int findSample(int n, int confidence[], int host[], int protocol[]) {
int dp[n][2] = {};
for (int i = 0; i < n; i++) {
dp[i][0] = confidence[i];
}
for (int i = n-1; i > 0; i--) {
int j = host[i];
if (protocol[i] == 0) {
dp[j][0] += dp[i][1]; // dont take invitee
dp[j][1] += max(dp[i][0], dp[i][1]); // free to do anything with invitee
} else if (protocol[i] == 1) {
dp[j][0] += max(dp[i][0], dp[i][1]); // free to do anything with invitee
dp[j][0] = max(dp[j][0], dp[j][1] + dp[i][0]); // as well as the case of taking host but not invitee (1 person case)
dp[j][1] += dp[i][1]; //dont take either
} else {
dp[j][0] = max(dp[j][0] + dp[i][1], dp[i][0] + dp[j][1]); // taking one is fine
dp[j][1] += dp[i][1]; // and so is taking none
}
return max(dp[0][0], dp[0][1]); //best is dependent on taking or not person 0, so just look at both.
}
}
컴파일 시 표준 에러 (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |