제출 #954843

#제출 시각아이디문제언어결과실행 시간메모리
954843ItamarFireworks (APIO16_fireworks)C++14
7 / 100
1 ms348 KiB
#include <iostream>
using namespace std;
#include <vector>
#define vi vector<int>
#define ll long long
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <cmath>
#include <math.h>
#define pll pair<ll,ll>
#define vll vector<ll>
#define pi pair<int,int>
#include <map>
#include <queue>
#define x first
#define y second
#define pd pair<double,double>

const int siz = 301;
int pad[siz];
int w[siz];
vi son[siz];
ll dp[siz][siz];
int main()
{
	int n, m;
	cin >> n >> m;
	vi v;
	for (int i = 1; i < n + m; i++) {
		int p, c;
		cin >> p >> c;
		p--;
		v.push_back(c);
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	for (int i = 0; i < m; i++) {
		ans += abs(v[m / 2] - v[i]);
	}
	cout << ans;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...