Submission #35667

# Submission time Handle Problem Language Result Execution time Memory
35667 2017-11-28T02:37:10 Z funcsr Fireworks (APIO16_fireworks) C++14
7 / 100
3 ms 9208 KB
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
vector<P> G[300000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, N-1+M) {
    int p, c;
    cin >> p >> c;
    p--;
    G[p].pb(P(i+1, c));
  }
  if (N > 1) return 1;
  vector<int> costs;
  for (P p : G[0]) costs.pb(p._2);
  sort(all(costs));
  int g = costs[costs.size()/2];
  long long sum = 0;
  for (int c : costs) sum += abs(c - g);
  cout << sum << "\n";
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9208 KB Output is correct
2 Correct 3 ms 9208 KB Output is correct
3 Correct 0 ms 9208 KB Output is correct
4 Correct 0 ms 9208 KB Output is correct
5 Correct 3 ms 9208 KB Output is correct
6 Correct 0 ms 9208 KB Output is correct
7 Correct 0 ms 9208 KB Output is correct
8 Correct 0 ms 9208 KB Output is correct
9 Correct 0 ms 9208 KB Output is correct
10 Correct 3 ms 9208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 9208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9208 KB Output is correct
2 Correct 3 ms 9208 KB Output is correct
3 Correct 0 ms 9208 KB Output is correct
4 Correct 0 ms 9208 KB Output is correct
5 Correct 3 ms 9208 KB Output is correct
6 Correct 0 ms 9208 KB Output is correct
7 Correct 0 ms 9208 KB Output is correct
8 Correct 0 ms 9208 KB Output is correct
9 Correct 0 ms 9208 KB Output is correct
10 Correct 3 ms 9208 KB Output is correct
11 Incorrect 0 ms 9208 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9208 KB Output is correct
2 Correct 3 ms 9208 KB Output is correct
3 Correct 0 ms 9208 KB Output is correct
4 Correct 0 ms 9208 KB Output is correct
5 Correct 3 ms 9208 KB Output is correct
6 Correct 0 ms 9208 KB Output is correct
7 Correct 0 ms 9208 KB Output is correct
8 Correct 0 ms 9208 KB Output is correct
9 Correct 0 ms 9208 KB Output is correct
10 Correct 3 ms 9208 KB Output is correct
11 Incorrect 0 ms 9208 KB Output isn't correct
12 Halted 0 ms 0 KB -