QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#673324#7787. Maximum Ratingyeah14#WA 0ms3708kbC++171.6kb2024-10-24 21:44:102024-10-24 21:44:15

Judging History

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

  • [2024-10-24 21:44:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3708kb
  • [2024-10-24 21:44:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 5;
// a[32];
using PII = pair<int, int>;
const int INF = 0x3f3f3f3f3f3f;
map<string, vector<PII>>mp;
map<int, string>mpp;
//int a[N];
int ans[N];
int ww[N];
int st[N],top=0;
const int mod = 998244353;
bool cmp(PII a, PII b) {
	return a.first > b.first;
}
bool cmp2(int a, int b) {
	return a > b;
}
int __gcd(int x, int y) {
	if (y == 0)return x;
	else return __gcd(y, x % y);
}
int fp(int a, int x) {
	int ans = 1;
	while (x) {
		if (x & 1)ans *= a;
		ans %= mod;
		a *= a;
		a %= mod;
		x >>= 1;
	}
	return ans%mod;
}

//vector<int>p[N];
int a[N];
map<PII, bool>p;//>0
void solve() {
	int n, q;
	cin >> n >> q;
	int sumz = 0, sumf = 0;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		if (a[i] < 0) {
			sumf += a[i];
			
		}
		else if (a[i] > 0) {
			p[{a[i], i}] = 1;
		}
	}
	while (q--) {
		int i, c;
		cin >> i >> c;
		//a[i] = c;
		if (a[i] >= 0 && c < 0) {
			if(c!=0)p.erase({ a[i], i });
			sumf += c;
			a[i] = c;
		}
		else if (a[i]<=0&&c > 0) {
			p[{c, i}] = 1;
			sumf -= a[i];
			a[i] = c;
		}
		else if (a[i] > 0) {
			p.erase({ a[i],i });
			if(c!=0)p[{c, i}] = 1;
			a[i] = c;
		}
		else if(a[i]<0) {
			sumf -= a[i];
			a[i] = c;
		}
		int maxx = p.size();
		int minn = 0;
		int ff = sumf;
		for (auto qq = p.begin(); qq != p.end(); qq++) {
			int t = (*qq).first.first;
			ff += t;
			if (ff > 0)minn++;
		}
		cout << maxx - minn+1<<endl;
	}
}



signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t=1;
	//cin >> t;
	while (t--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

1 1
1000000000
1 1000000000

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

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:

946
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
1
1
1
...

result:

wrong answer 2nd numbers differ - expected: '65', found: '1'