이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "friend.h"
using namespace std;
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
#define pb push_back
int findSample(int n, int* confidence, int* host, int* protocol){
int host_v = confidence[n-1], mv = 0, ans = 0;
for(int i = n-1; i; i--){
host_v = confidence[i];
mv = confidence[host[i]];
if(protocol[i] == 0){
if(host_v > mv){
ans += host_v; confidence[host[i]] = 0;
}
else{
ans += host_v; confidence[host[i]] -= host_v;
}
}
else if(protocol[i] == 1){
confidence[host[i]] += host_v;
}
else{
confidence[host[i]] = max(host_v, mv);
}
}
ans += confidence[0];
return ans;
}
/*
int confidence[101], host[101], protocol[101];
signed main(){
int n; cin >> n;
for(int i = 0; i < n; i++){
cin >> confidence[i];
}
for(int i = 1; i < n; i++){
cin >> host[i] >> protocol[i];
}
cout << findSample(n,confidence,host,protocol) << "\n";
}
*/
# | 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... |