QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#705034 | #7787. Maximum Rating | Fluoresce | WA | 1ms | 7928kb | C++20 | 2.1kb | 2024-11-02 21:56:15 | 2024-11-02 21:56:16 |
Judging History
answer
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define debug(a) cout<<a<<'\n'
#define Pll pair<ll,ll>
#define PII pair<int,int>
#define ft first
#define sd second
#define vec vector
#define pushk push_back
#define ump unordered_map
#define pl p<<1
#define pr p<<1|1
using namespace std;
const int N = 2e5 + 10, M = 1e4 + 10, mod = 998244353;
const ll inf = 1e18;
const ld eps = 1e-13;
int mov[4][2] = { {0,1},{1,0},{-1,0},{0,-1} }, dx, dy, _ = 1, __ = 1;
void bout(bool f) {
if (f)cout << "YES\n";
else cout << "NO\n";
}
ll n, m, k;
Pll tr[N<<3];
ll v[N<<1],a[N];
int q[N][2];
void upd(int s,int t,int p,int k,int x){
if(s==t){
tr[p].sd+=x;
tr[p].ft=tr[p].sd*v[s];
return;
}
int m=s+t>>1;
if(k<=m)upd(s,m,pl,k,x);
else upd(m+1,t,pr,k,x);
tr[p]={tr[pl].ft+tr[pr].ft,tr[pl].sd+tr[pr].sd};
}
int query(int s,int t,int p,ll sum){
if(s==t){
if(tr[p].ft>sum)return sum/v[s]+1;
else return n+1;//n==1
}
int m=s+t>>1;
if(tr[pl].ft>sum)return query(s,m,pl,sum);
else if(tr[p].ft>sum)return tr[pl].sd+query(m+1,t,pr,sum-tr[pl].ft);
else return n+1;
}
void ini() {
}
void solve() {
cin>>n>>m;
int x,y,z=0;
for(int i=1;i<=n;++i){
cin>>a[i];
v[i]=a[i];
if(a[i]>0)++z;
}
for(int i=1;i<=m;++i){
cin>>q[i][0]>>q[i][1];
v[i+n]=q[i][1];
}
sort(v+1,v+n+m+1);
int cnt=unique(v+1,v+n+m+1)-v;
unordered_map<int,int>mp;
for(int i=1;i<=cnt;++i)mp[v[i]]=i;
for(int i=1;i<=n;++i)upd(1,cnt,1,mp[a[i]],1);
for(int i=1;i<=m;++i){
x=q[i][0];
y=q[i][1];
if(a[x]>0)--z;
if(y>0)++z;
upd(1,cnt,1,mp[a[x]],-1);
upd(1,cnt,1,mp[y],1);
a[x]=y;
cout<<z-(n-query(1,cnt,1,0)+1)+1<<'\n';
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
streambuf *cinbp=cin.rdbuf(),*coutbp=cout.rdbuf();
ifstream fin("in.txt");
ofstream fout("out.txt");
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#endif
//cin >> _;
__ = _;
ini();
while (_--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7928kb
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: 1ms
memory: 7928kb
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: 1ms
memory: 7652kb
input:
1 1 1000000000 1 1000000000
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5656kb
input:
1 1 -1000000000 1 -1000000000
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 5728kb
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 65 252 410 915 592 983 487 343 899 809 432 586 587 139 464 804 84 476 699 504 149 579 0 375 856 545 166 140 657 568 509 275 710 873 430 537 879 301 1 298 970 923 510 984 642 55 879 941 344 464 788 917 994 571 610 491 442 926 101 986 840 624 613 425 345 816 423 275 221 317 113 386 116 469 260 498...
result:
wrong answer 24th numbers differ - expected: '352', found: '0'