Submission #471025

#TimeUsernameProblemLanguageResultExecution timeMemory
471025iulia13Friend (IOI14_friend)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 5;
int dp[N][2];
int c[N], h[N], p[N];
int findSample(int n, int confidence[], int host[], int protocol[])
{
    int i;
    for (i = 0; i < n; i++)
        dp[i][1] = confidence[i];
    for (i = n - 1; i; i--)
    {
        int j = host[i];
        if (protocol[i] == 0)
        {
            dp[j][0] += max(dp[i][0], dp[i][1]);
            dp[j][1] += dp[i][0];
            continue;
        }
        int t = dp[i][0];
        if (protocol[i] == 1)
            t = max(t, dp[i][1]);

        dp[j][1] += t;
        dp[j][1] = max(dp[j][1], dp[j][0] + dp[i][1]);
        dp[j][0] += dp[i][0];
    }
    return max(dp[0][0], dp[0][1]);
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> c[i];
    for (int i = 1; i < n; i++)
        cin >> h[i] >> p[i];
    cout << findSample(n, c, h, p);
    return 0;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cc7YG3rz.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc2ZYAQB.o:friend.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status