Submission #38726

# Submission time Handle Problem Language Result Execution time Memory
38726 2018-01-06T10:43:36 Z Waschbar Fireworks (APIO16_fireworks) C++14
0 / 100
6 ms 11392 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 300000;

int N, n, m, ans;
int dis[MAXN+1], pr[MAXN+1];
vector < vector < int > > g(MAXN+1);

int main() {

    cin >> n >> m;
    N = n+m;
    for(int i = 2; i <= N; i++) {
        cin >> pr[i] >> dis[i];
        g[pr[i]].push_back(i);
        g[i].push_back(pr[i]);
    }

    if(n == 1) {
        vector < int > vv;
        for(int i = 2; i <= N; i++)
            vv.push_back(dis[i]);
        sort(vv.begin(),vv.end());
        int xx = vv[vv.size()/2];
        for(int i = 0; i < vv.size(); i++)
            ans += abs(vv[i]-xx);
        cout << ans;
        return 0;
    }

    return 0;
}

Compilation message

fireworks.cpp: In function 'int main()':
fireworks.cpp:26:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0; i < vv.size(); i++)
                          ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11392 KB Output is correct
2 Correct 3 ms 11392 KB Output is correct
3 Incorrect 3 ms 11392 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 11392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11392 KB Output is correct
2 Correct 3 ms 11392 KB Output is correct
3 Incorrect 3 ms 11392 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11392 KB Output is correct
2 Correct 3 ms 11392 KB Output is correct
3 Incorrect 3 ms 11392 KB Output isn't correct
4 Halted 0 ms 0 KB -