QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#699143 | #7622. Yet Another Coffee | Regina# | WA | 1ms | 5784kb | C++14 | 2.7kb | 2024-11-02 02:03:24 | 2024-11-02 02:03:24 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+10,inf=1e18;
//struct Tree{int l,r,mn,add,pos;}tree[N<<2];
int t,n,m,lstans,a[N],mnpos[N];//set<pair<int,int> >s;
inline int read(){
int r=0,f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar();
return r*f;
}
void put(int x){
if(x<0){putchar('-');x=~x+1;}
if(x>9)put(x/10);
putchar(x%10+'0');
}
/*
void spread(int p){
if(!tree[p].add)return;
tree[p<<1].add+=tree[p].add;
tree[p<<1|1].add+=tree[p].add;
tree[p<<1].mn+=tree[p].add;
tree[p<<1|1].mn+=tree[p].add;
tree[p].add=0;
}
void build(int p,int l,int r){
tree[p].l=l,tree[p].r=r,tree[p].add=0;
if(l==r){tree[p].mn=a[l],tree[p].pos=l;return;}
int mid=(l+r)>>1;build(p<<1,l,mid),build(p<<1|1,mid+1,r);
if(tree[p<<1].mn<=tree[p<<1|1].mn)
tree[p].mn=tree[p<<1].mn,tree[p].pos=tree[p<<1].pos;
else tree[p].mn=tree[p<<1|1].mn,tree[p].pos=tree[p<<1|1].pos;
}
void change(int p,int l,int r,int x){
if(l<=tree[p].l&&tree[p].r<=r){
tree[p].mn+=x,tree[p].add+=x;return;
}spread(p);
int mid=(tree[p].l+tree[p].r)>>1;
if(l<=mid)change(p<<1,l,r,x);
if(r>mid)change(p<<1|1,l,r,x);
if(tree[p<<1].mn<=tree[p<<1|1].mn)
tree[p].mn=tree[p<<1].mn,tree[p].pos=tree[p<<1].pos;
else tree[p].mn=tree[p<<1|1].mn,tree[p].pos=tree[p<<1|1].pos;
}
void update(int p,int x,int v){
if(tree[p].l==tree[p].r){tree[p].mn=v;return;}
spread(p);
int mid=(tree[p].l+tree[p].r)>>1;
if(x<=mid)update(p<<1,x,v);
else update(p<<1|1,x,v);
if(tree[p<<1].mn<=tree[p<<1|1].mn)
tree[p].mn=tree[p<<1].mn,tree[p].pos=tree[p<<1].pos;
else tree[p].mn=tree[p<<1|1].mn,tree[p].pos=tree[p<<1|1].pos;
}*/
signed main(){
// freopen("cpp.in","r",stdin);
// freopen("cpp.out","w",stdout);
t=read();
while(t--){
n=read(),m=read(),lstans=0;
for(int i=1,mn=inf;i<=n;i++){
a[i]=read(),mnpos[i]=mnpos[i-1];
if(a[i]<mn)mn=a[i],mnpos[i]=i;
}
for(int i=1;i<=m;i++){
int rr=read(),w=read();
// change(1,1,rr,-w);
// s.insert(make_pair(rr,w));
a[mnpos[rr]]-=w;
}
sort(a+1,a+1+n);
for(int T=1;T<=n;T++){
lstans+=a[T],put(lstans),printf(" ");/*int nw=tree[1].pos;
auto it=lower_bound(s.begin(),s.end(),make_pair(nw,0ll)),it1=it;
for(;it!=s.end();)change(1,1,it->first,it->second),it1=it++,s.erase(it1);
update(1,nw,inf);*/
}puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5784kb
input:
5 10 14 17 37 59 65 53 73 68 177 160 111 10 177 5 193 2 30 3 63 2 339 3 263 5 178 2 190 9 23 10 328 10 200 9 8 3 391 6 230 12 9 152 306 86 88 324 59 18 14 42 260 304 55 3 50 2 170 1 252 7 811 1 713 7 215 10 201 4 926 8 319 19 20 182 74 180 201 326 243 195 31 170 263 284 233 48 166 272 281 179 116 31...
output:
-2596 -2559 -2506 -2447 -2382 -2314 -2241 -2130 -1970 -1793 -1008 -1991 -2881 -3387 -3345 -3290 -3231 -3143 -2883 -2579 -2273 -1949 -4500 -6315 -6422 -6374 -6258 -6092 -5922 -5743 -5563 -5368 -5167 -4934 -4691 -4428 -4156 -3875 -3591 -3272 -2946 -1792 -2804 -2572 -2140 -1707 -1238 -768 -274 243 1...
result:
wrong answer 11th numbers differ - expected: '-3505', found: '-1008'