/ WOJ /

记录详情

System Error


  
Testdata configuration incorrect.
Memory limit larger than memory_max

代码

#include <bits/extc++.h>
#define endl '\n'
typedef long long ll;
#define int ll
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

void Main()
{
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int& x : p)
	{
		cin >> x;
	}
	vector<int> w(n);
	for (int& x : w)
	{
		cin >> x;
	}
	vector<pair<int, int>> a(n);
	for (auto [aa, pp, ww] : views::zip(a, p, w))
	{
		aa = {pp, ww};
	}
	ranges::sort(a);
	int res = -1;
	for (int i = 0; i < n; ++i)
	{
		const int tg = a[i].first;
		vector<int> cst;
		for (int j = 0; j < n; ++j)
		{
			if (a[j].first <= tg)
			{
				cst.push_back((tg - a[j].first) * a[j].second);
			}
		}
		if (static_cast<int>(cst.size()) < k)
		{
			continue;
		}
		ranges::sort(cst);
		int cur = 0;
		for (int j = 0; j < k; ++j)
		{
			cur += cst[j];
		}
		if (res == -1 || cur < res)
		{
			res = cur;
		}
	}
	cout << res << endl;
}

// #define CP_MULTI_TEST_CASES

signed main()
{
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	int t = 1;
#ifdef CP_MULTI_TEST_CASES
	cin >> t;
#endif
	while (t--)
	{
		Main();
	}
	return cout << flush, fflush(stdout), 0;
}

信息

递交者
类型
递交
题目
P1000 云剪贴板
题目数据
下载
语言
C++
递交时间
2026-05-05 14:40:58
评测时间
2026-05-07 17:45:36
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes