QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#678738#7787. Maximum Ratingsurenjamts#WA 0ms3632kbC++17904b2024-10-26 15:56:462024-10-26 15:56:51

Judging History

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

  • [2024-10-26 15:56:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2024-10-26 15:56:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define F first
#define S second
typedef tree<
int,
null_type,
less_equal<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
ordered_set s;
int n,q;
int a[200005];	   
int sum;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cin>>n>>q;
	for(int i=1; i<=n; i++){
		cin>>a[i];
		if(a[i]<0){
			sum+=a[i];
		}
		else if(a[i]>0){
			s.insert(a[i]);
		}
	}
	while(q--){
		int idx, val;
		cin>>idx>>val;
		if(a[idx]<0){
			sum-=a[idx];
		}
		else if(a[idx]>0){
			s.erase(s.upper_bound(a[idx]));
//			s.insert(val);
		}
		
		if(val>0){
			s.insert(val);
		}else if(val<0){
			sum+=val;
		}
//		cout<<"SUM"<<sum<<endl;
		cout<<s.order_of_key(-sum)+1<<endl;
		a[idx]=val;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 0ms
memory: 3584kb

input:

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

output:

1
2
1
2
1

result:

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

Test #3:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

1 1
1000000000
1 1000000000

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

1 1
-1000000000
1 -1000000000

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3632kb

input:

1000 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
100...

result:

wrong answer 1st numbers differ - expected: '946', found: '1000'