답안 #38727

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38727 2018-01-06T10:44:33 Z Waschbar Fireworks (APIO16_fireworks) C++14
7 / 100
3 ms 13736 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 300000;

long long N, n, m, ans;
long long 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 < long long > vv;
        for(int i = 2; i <= N; i++)
            vv.push_back(dis[i]);
        sort(vv.begin(),vv.end());
        long long 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++)
                          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 13736 KB Output is correct
2 Correct 0 ms 13736 KB Output is correct
3 Correct 0 ms 13736 KB Output is correct
4 Correct 3 ms 13736 KB Output is correct
5 Correct 3 ms 13736 KB Output is correct
6 Correct 0 ms 13736 KB Output is correct
7 Correct 0 ms 13736 KB Output is correct
8 Correct 0 ms 13736 KB Output is correct
9 Correct 0 ms 13736 KB Output is correct
10 Correct 0 ms 13736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 13736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 13736 KB Output is correct
2 Correct 0 ms 13736 KB Output is correct
3 Correct 0 ms 13736 KB Output is correct
4 Correct 3 ms 13736 KB Output is correct
5 Correct 3 ms 13736 KB Output is correct
6 Correct 0 ms 13736 KB Output is correct
7 Correct 0 ms 13736 KB Output is correct
8 Correct 0 ms 13736 KB Output is correct
9 Correct 0 ms 13736 KB Output is correct
10 Correct 0 ms 13736 KB Output is correct
11 Incorrect 3 ms 13736 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 13736 KB Output is correct
2 Correct 0 ms 13736 KB Output is correct
3 Correct 0 ms 13736 KB Output is correct
4 Correct 3 ms 13736 KB Output is correct
5 Correct 3 ms 13736 KB Output is correct
6 Correct 0 ms 13736 KB Output is correct
7 Correct 0 ms 13736 KB Output is correct
8 Correct 0 ms 13736 KB Output is correct
9 Correct 0 ms 13736 KB Output is correct
10 Correct 0 ms 13736 KB Output is correct
11 Incorrect 3 ms 13736 KB Output isn't correct
12 Halted 0 ms 0 KB -