QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#790786#7787. Maximum Ratingzhilin#WA 1ms5644kbC++14542b2024-11-28 15:22:092024-11-28 15:22:22

Judging History

你现在查看的是最新测评结果

  • [2024-11-28 15:22:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5644kb
  • [2024-11-28 15:22:09]
  • 提交

answer

#include<bits/stdc++.h>
#define maxn 1000005
using namespace std;
long long A[maxn],pos[maxn];
int main(){
	long long n,q,i,x,v,j,tot=0,fus=0,maxs,mins;
	cin>>n>>q;
	for(i=1;i<=n;i++){
		cin>>A[i];
	}
	for(i=1;i<=q;i++){
		tot=0;
		cin>>x>>v;
		A[x]=v;
		for(j=1;j<=n;j++){
    		if(A[j]>0)pos[++tot]=A[j];
	    	if(A[j]<0)fus+=A[j];			
		}
		sort(pos+1,pos+1+tot);
		for(j=1;j<=tot;j++){
			if(fus+pos[j]>0)break;
			else fus+=pos[j];
		}
		maxs=tot;
		mins=tot-j+1;
		cout<<maxs-mins+1<<'\n'; 
    }
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 5
1 2 3
3 4
2 -2
1 -3
3 1
2 1

output:

1
2
2
2
3

result:

ok 5 number(s): "1 2 2 2 3"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5644kb

input:

3 5
1 2 3
3 4
2 -2
1 3
3 1
2 1

output:

1
2
2
2
2

result:

wrong answer 3rd numbers differ - expected: '1', found: '2'