QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#790786 | #7787. Maximum Rating | zhilin# | WA | 1ms | 5644kb | C++14 | 542b | 2024-11-28 15:22:09 | 2024-11-28 15:22:22 |
Judging History
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'