Submission #61190

# Submission time Handle Problem Language Result Execution time Memory
61190 2018-07-25T10:29:17 Z Flugan42 Fireworks (APIO16_fireworks) C++14
7 / 100
4 ms 596 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double lld;
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define per(i,a,b) for(ll i = a; i >= b; i--)
#define inf 1000000000000000000
#define all(x) x.begin(),x.end()
#define sz(x) (ll)(x).size()
#define trav(a,x) for(auto a : x)

ll n,m,p,c;
vii tree,_;
vector<vii> edges;
vi firstcase;

int main(){
  cin >> n >> m;
  edges.assign(n+m,_);
  rep(i,0,n-1){
    cin >> p >> c; p--;
    tree.push_back(make_pair(p,c));
    edges[i+1].push_back(make_pair(p,c));
    edges[p].push_back(make_pair(i+1,c));
  }
  rep(i,n-1,m+n-1){
    cin >> p >> c; p--;
    tree.push_back(make_pair(p,c));
    edges[i+1].push_back(make_pair(p,c));
    edges[p].push_back(make_pair(i+1,c));
    firstcase.push_back(c);
  }
  sort(all(firstcase));
  ll res = 0;
  rep(i,0,m) res += abs(firstcase[i]-firstcase[m/2]);
  cout << res << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 392 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 4 ms 596 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 392 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 4 ms 596 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Incorrect 2 ms 596 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 392 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 4 ms 596 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Incorrect 2 ms 596 KB Output isn't correct
12 Halted 0 ms 0 KB -