QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398933#8544. Colorful Graph 2PetroTarnavskyi#WA 1ms3844kbC++201.5kb2024-04-25 20:04:002024-04-25 20:04:01

Judging History

你现在查看的是最新测评结果

  • [2024-04-25 20:04:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3844kb
  • [2024-04-25 20:04:00]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

void solve()
{
	int n, m;
	cin >> n >> m;
	VI a(n + 1), b(n);
	FOR(i, 1, n + 1)
		cin >> a[i];
	if (a.back() < m)
		a.PB(m);
	for (int& bi : b)
		cin >> bi;
	sort(ALL(b));
	int curProb = 0;
	vector<VI> vec(SZ(a) - 1);
	int ptr = 0;
	FOR(i, 0, n)
	{
		curProb += b[i];
		if (curProb >= m)
			break;
		while (a[ptr + 1] <= curProb)
		{
			ptr++;
		}
		vec[ptr].PB(curProb);
	}
	FOR(i, 0, SZ(vec))
	{
		cerr << i << endl;
		for (int x : vec[i])
			cerr << x << " ";
		cerr << "\n---\n";
	}
	cerr << "--------\n";
	priority_queue<int> pq;
	FOR(i, 0, n + 47)
		pq.push(0);
	int ans = 0;
	RFOR(i, SZ(a) - 1, 0)
	{
		RFOR(j, SZ(vec[i]), 0)
		{
			if (j > 0)
			{
				ans += pq.top();
				pq.pop();
			}
			else
			{
				int le = vec[i][0] - a[i];
				int ri = a[i + 1] - vec[i][0];
				int mx = pq.top();
				pq.pop();
				if (mx >= ri)
				{
					ans += mx;
					pq.push(le + ri);
				}
				else
				{
					ans += ri;
					pq.push(mx + le);
				}
			}
		}
	}
	cout << ans << "\n";
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	while (t--)
		solve();
	return 0;
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3844kb

input:

3
3 0
4 1
1 3
6 3
0 2
2 4
4 0

output:

0
0
4

result:

wrong answer Token parameter [name=S] equals to "0", doesn't correspond to pattern "[BR]{1,200000}" (test case 1)