QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#698128#9528. New Energy VehiclewuyunzhishiCompile Error//C++141.3kb2024-11-01 17:35:262024-11-01 17:35:26

Judging History

This is the latest submission verdict.

  • [2024-11-01 17:35:26]
  • Judged
  • [2024-11-01 17:35:26]
  • Submitted

answer

#include <bits/stdc++.h>
using ll = long long;
int inf = 0x3f3f3f3f;
void solve() {
	int n, m; std::cin >> n >> m;
	std::vector<ll> a(n + 1), x(m + 1, 0), t(m + 1, 0), able(m + 1, 0), prior(n + 1, inf);
	for(int i = 1; i <= n; i++) std::cin >> a[i];
	for(int i = 1; i <= m; i++) std::cin >> x[i] >> t[i];

	auto cmp = [&](int x, int y) {
		return prior[x] > prior[y];
	};
	std::priority_queue<int, std::vector<int>, decltype(cmp)> pq(cmp);
	std::vector g(n + 1, std::deque<int>());
	
	for(int i = 1; i <= m; i++) {
		g[t[i]].push_back(x[i]);
	}
	for(int i = 1; i <= n; i++) g[i].push_back(inf);
	for(int i = 1; i <= n; i++) prior[i] = g[i].front();
	for(int i = 1; i <= n; i++) pq.push(i);
	std::vector<ll> b = a;
	ll d = 0;
	for(int i = 1; i <= m; i++) {
		g[t[i]].pop_front();
		prior[t[i]] = g[t[i]].front();
		while(!pq.empty() && d < x[i]) {
			int u = pq.top();
			if(b[u] >= x[i] - d) {
				b[u] -= x[i] - d;
				d = x[i];
				if(u == t[i]) pq.pop();
				break;
			}
			else {
				d += b[u];
				b[u] = 0;
				pq.pop();
			}
		}
		b[t[i]] = a[t[i]];
		pq.push(t[i]);
	}
	for(int i = 1; i <= n; i++) d += b[i];
	
	std::cout << d << '\n';
	
}

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

Details

answer.code: In function ‘void solve()’:
answer.code:14:21: error: missing template arguments before ‘g’
   14 |         std::vector g(n + 1, std::deque<int>());
      |                     ^
answer.code:17:17: error: ‘g’ was not declared in this scope
   17 |                 g[t[i]].push_back(x[i]);
      |                 ^
answer.code:19:37: error: ‘g’ was not declared in this scope
   19 |         for(int i = 1; i <= n; i++) g[i].push_back(inf);
      |                                     ^
answer.code:20:48: error: ‘g’ was not declared in this scope
   20 |         for(int i = 1; i <= n; i++) prior[i] = g[i].front();
      |                                                ^
answer.code:25:17: error: ‘g’ was not declared in this scope
   25 |                 g[t[i]].pop_front();
      |                 ^