QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#681333#9528. New Energy Vehicleucup-team3695#WA 0ms3780kbC++201.2kb2024-10-27 05:29:572024-10-27 05:29:57

Judging History

This is the latest submission verdict.

  • [2024-10-27 05:29:57]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3780kb
  • [2024-10-27 05:29:57]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define sz(C)		 ((int)size(C))
#define all(C)		 begin(C), end(C)
#define rep(i, a, b) for (int i = (a); i < (b); i++)

int	 t = 1;
void pre();
void go();

int main()
{
	pre();

	while (t--)
		go();
}

void pre()
{
	cin.tie(0)->sync_with_stdio(0);
	cin >> t;
}

vector<int>														  A, C;
vector<pair<int, int>>											  X;
vector<vector<int>>												  T;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> Q;

void go()
{
	int n, m;
	cin >> n >> m;
	A.resize(n);
	T.assign(n, {});
	X.resize(m);
	for (int &a : A)
		cin >> a;
	C = A;
	for (auto &[x, i] : X)
	{
		cin >> x >> i;
		i--;
		T[i].push_back(x);
	}
	for (int i = 0; i < n; i++)
	{
		T[i].push_back(INT_MAX);
		reverse(all(T[i]));
		Q.emplace(T[i].back(), i);
	}

	int pos = 0;
	for (auto [x, i] : X)
	{
		while (!Q.empty() && pos < x)
		{
			auto [y, j] = Q.top();
			int amt		= min(C[j], x - pos);
			pos += amt;
			C[j] -= amt;
			if (C[j] == 0)
				Q.pop();
		}
		if (pos < x)
			break;
		if (C[i] > 0)
			Q.pop();
		C[i] = A[i];
		T[i].pop_back();
		Q.emplace(T[i].back(), i);
	}

	cout << pos + accumulate(all(C), 0ll) << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3780kb

input:

2
3 1
3 3 3
8 1
2 2
5 2
1 2
2 1

output:

12
9

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3532kb

input:

6
3 2
2 2 2
6 1
7 1
2 2
3 3
2 1
6 2
2 3
2 2
5 1
7 2
9 1
2 2
3 3
2 1
6 2
1 1
999999999
1000000000 1
1 1
1000000000
1000000000 1

output:

9
11
4
11
1999999999
2000000000

result:

wrong answer 5th lines differ - expected: '999999999', found: '1999999999'