QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#673296 | #7787. Maximum Rating | yeah14# | WA | 3ms | 3708kb | C++17 | 1.6kb | 2024-10-24 21:37:17 | 2024-10-24 21:37:18 |
Judging History
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) {
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 (c > 0) {
p.erase({ a[i],i });
p[{c, i}] = 1;
a[i] = c;
}
else {
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: 3644kb
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: 3552kb
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: 3708kb
input:
1 1 -1000000000 1 -1000000000
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 3ms
memory: 3652kb
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'