QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#751806#9528. New Energy VehiclezsofustbWA 1ms5688kbC++201.0kb2024-11-15 20:48:292024-11-15 20:48:29

Judging History

This is the latest submission verdict.

  • [2024-11-15 20:48:29]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5688kb
  • [2024-11-15 20:48:29]
  • Submitted

answer

#include<bits/stdc++.h>

#define MAXN 100005

using namespace std;

int n,m;
long long a[MAXN];
struct node
{
	long long x,t;
}b[MAXN];
int vis[MAXN];

int cmp(node a1,node b1)
{
	return a1.x<b1.x;
}

void solve()
{
	int i,j;
	cin>>n>>m;
	long long sum=0;
	for(i=1;i<=n;i++)
	{
		vis[i]=0;
		cin>>a[i];
		sum+=a[i];
	}
	for(i=1;i<=m;i++)
	{
		cin>>b[i].x>>b[i].t;
	}
	sort(b+1,b+1+m,cmp);
	int ov=0;
	bool flag=0;
	for(i=1;i<=m;i++)
	{
		if(ov+sum<b[i].x)
		{
			cout<<ov+sum<<endl;
			flag=1;
			break;
		}
		if(vis[b[i].t]==0)
		{
			int tmp=b[i].x-b[i-1].x;
			if(tmp>=a[b[i].t]) ov+=a[b[i].t];
			else ov+=tmp;
		}
		else
		{
			for(i=1;i<=n;i++)
			{
				int tmp=b[i].x-b[i-1].x;
				if(tmp>=a[b[i].t]) ov+=a[b[i].t];
				else ov+=tmp;
			}
		}
		vis[b[i].t]=b[i].x;
	}
	if(flag) return;
	cout<<ov+sum<<endl;
}

int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j;

	int T;
	cin>>T;
	while(T--)
		solve();

	return 0;
}

详细

Test #1:

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

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

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:

4
11
4
11
999999999
2000000000

result:

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