QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#687320#9528. New Energy Vehiclewangxi527#WA 1ms7668kbC++17720b2024-10-29 18:18:112024-10-29 18:18:13

Judging History

This is the latest submission verdict.

  • [2024-10-29 18:18:13]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 7668kb
  • [2024-10-29 18:18:11]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[200010],pos[200010];
struct abc{
	int now,charg;
};
abc s[200010];
bool cmp(abc x,abc y){
	return x.now<y.now;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		int sum=0,ans=0;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			sum+=a[i];
			ans+=a[i];
			pos[i]=0;
		}
		for(int i=1;i<=m;i++){
			cin>>s[i].now>>s[i].charg;
		}
		sort(s+1,s+m+1,cmp);
		for(int i=1;i<=m;i++){
			if(sum<s[i].now)break;
			sum+=min({s[i].now-pos[s[i].charg],a[s[i].charg],ans-sum+s[i].now});
			pos[s[i].charg]=i;
		}
		cout<<sum<<"\n";
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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:

10
11
4
11
999999999
2000000000

result:

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