제출 #238364

#제출 시각아이디문제언어결과실행 시간메모리
238364caoash친구 (IOI14_friend)C++14
100 / 100
37 ms2680 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...