QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722789#9528. New Energy VehiclereverSillyWA 1ms7872kbC++231.2kb2024-11-07 20:12:022024-11-07 20:12:03

Judging History

This is the latest submission verdict.

  • [2024-11-07 20:12:03]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 7872kb
  • [2024-11-07 20:12:02]
  • Submitted

answer

// CCPC 2024 Harbin Site J New Energy Vehicle
// https://contest.ucup.ac/contest/1817/problem/9528?v=1
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
constexpr int mxn{200005};
int T,n,m,a[mxn],nx[mxn],cura[mxn],last[mxn];
struct{i64 x;int t;}xt[mxn];
int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin>>T;
	while(T--)
	{
		cin>>n>>m;
		for(int i=0;i<n;++i)
			cin>>a[i];
		copy_n(a,n,cura);
		for(int i=0;i<m;++i)
		{
			cin>>xt[i].x>>xt[i].t;
			--xt[i].t;
		}
		xt[m].x=1e18;
		fill_n(last,n,1e18);
		for(int i=m-1;i>=0;--i)
		{
			nx[i]=last[xt[i].t];
			last[xt[i].t]=xt[i].x;
		}
		priority_queue<array<int,2>>Q;
		for(int i=0;i<n;++i)
			Q.push({-last[i],i});
		i64 ans=0,i=0;
		while(!Q.empty())
		{
			if(ans==xt[i].x)
			{
				if(Q.top()[1]==xt[i].t)
					Q.pop();
				cura[xt[i].t]=a[xt[i].t];
				if(nx[i]<1e18)
					Q.push({-nx[i],xt[i].t});
				++i;
			}
			auto[_,u]=Q.top();
			// cerr<<u<<' '<<ans<<'\n';
			i64 dist=min((i64)cura[u],xt[i].x-ans);
			cura[u]-=dist;
			ans+=dist;
			if(cura[u]==0)
				Q.pop();
		}
		cout<<ans<<'\n';
	}
	return 0;
}
// 1
// 3 1
// 3 3 3
// 8 1

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5696kb

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: 1ms
memory: 7872kb

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:

6
11
4
11
999999999
1000000000

result:

wrong answer 1st lines differ - expected: '9', found: '6'