QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#693761#9528. New Energy VehicleNyanya_#WA 0ms3612kbC++231.2kb2024-10-31 16:42:182024-10-31 16:42:18

Judging History

This is the latest submission verdict.

  • [2024-10-31 16:42:18]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3612kb
  • [2024-10-31 16:42:18]
  • Submitted

answer

#include<bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin>>T;
	while (T--)
	{
		int n,m;
		cin>>n>>m;
		vector<int>a(n+5),b(n+5),cnt(n+5);
		vector<int>nxt(m+5,m+1),id(n+5);
		vector<pii>x(m+5);
		priority_queue<int,vector<int>, greater<int>>q;
		long long sum=0;
		for (int i=1;i<=n;++i) cin>>a[i],b[i]=a[i];
		for (int i=1;i<=m;++i) cin>>x[i].first>>x[i].second,cnt[x[i].second]++,nxt[id[x[i].second]]=i,id[x[i].second]=i;
		for (int i=1;i<=m;++i) q.push(i);
		for (int i=1;i<=n;++i) 
			if (!cnt[i]) sum+=a[i];
		long long d=0;
		for (int i=1;i<=m;++i)
		{
			while (!q.empty()&&a[x[q.top()].second]<=x[i].first-d)
			{
				d+=a[x[q.top()].second];
				a[x[q.top()].second]=0;
				q.pop();
			}
			if (q.empty()) 
			{
				if (d+sum<x[i].first) {d+=sum;sum=0;break;}
				else sum-=x[i].first-d,d=x[i].first;
			}
			if (d!=x[i].first)
			{
				a[x[q.top()].second]-=x[i].first-d;
				d=x[i].first;
			}
			a[x[i].second]=b[x[i].second];
			q.push(nxt[i]);
			cnt[x[i].second]--;
			if (!cnt[x[i].second]) sum+=a[x[i].second];
		}
		d+=sum;
		cout<<d<<"\n";
	}
}

详细

Test #1:

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

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: 3556kb

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
12
4
12
999999999
2000000000

result:

wrong answer 2nd lines differ - expected: '11', found: '12'