Submission #253226

# Submission time Handle Problem Language Result Execution time Memory
253226 2020-07-27T13:52:34 Z aZvezda Friend (IOI14_friend) C++14
Compilation error
0 ms 0 KB
#include "friend.h"

// Find out best sample

const int MAX_N = 1e6 + 10;
int dp[MAX_N];

int findSample(int n, int confidence[], int host[], int protocol[]){
    for(int i = 0; i < n; i ++) {
        dp[i] = confidence[i];
    }
    for(int i = n - 1; i > 0; i --) {
        if(protocol[i] == 1) {
            dp[host[i]] -= min(dp[i], dp[host[i]])
            ans += dp[i];
        } else if(protocol[i] == 2) {
            dp[host[i]] += dp[i];
        } else {
            if(dp[i] > dp[host[i]]) {
                dp[host[i]] = dp[i];
            }
        }
    }
	return ans + dp[0];
}

Compilation message

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:14:28: error: 'min' was not declared in this scope
             dp[host[i]] -= min(dp[i], dp[host[i]])
                            ^~~
friend.cpp:24:9: error: 'ans' was not declared in this scope
  return ans + dp[0];
         ^~~