QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#115723 | #6630. Triangle Collection | youngsystem | 0 | 1ms | 5864kb | C++20 | 1.3kb | 2023-06-26 17:08:03 | 2023-06-26 17:08:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
struct tree
{
int l,r,het,maxn;
}a[800004];
int ys[200005],f[200005];
void build(int l,int r,int k)
{
a[k].l=l;
a[k].r=r;
if(l==r)
{
a[k].het=f[l];
a[k].maxn=max(0,f[l]);
return;
}
build(l,(l+r)>>1,k<<1);
build(((l+r)>>1)+1,r,k<<1|1);
a[k].het=a[k<<1].het+a[k<<1|1].het;
a[k].maxn=max(a[k<<1].maxn,a[k<<1].het+a[k<<1|1].maxn);
}
void change(int x,int k,int y)
{
if(a[k].l==a[k].r)
{
a[k].het=max(y,0);
a[k].maxn=y;
return;
}
if(x<=a[k<<1].r)change(x,k<<1,y);
else change(x,k<<1|1,y);
a[k].het=a[k<<1].het+a[k<<1|1].het;
a[k].maxn=max(a[k<<1].maxn,a[k<<1].het+a[k<<1|1].maxn);
}
int main()
{
int n,q,zs=0;
n=read();
q=read();
for(int i=1;i<=n;i++)
{
ys[i]=read();
zs+=ys[i]/2;
f[i]+=ys[i]/2;
f[(i+1)/2]-=(ys[i]%2);
}
int x,y;
for(int i=1;i<=q;i++)
{
x=read();
y=read();
f[x]-=ys[x]/2;
f[(x+1)/2]+=(ys[x]%2);
zs-=ys[x]/2;
ys[x]+=y;
f[x]+=ys[x]/2;
f[(x+1)/2]-=(ys[x]%2);
zs+=ys[x]/2;
change(x,1,f[x]);
change((x+1)/2,1,f[(x+1)/2]);
printf("%d\n",zs-(a[1].maxn+2)/3);
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 1ms
memory: 5864kb
input:
1 23 1485 1 -12 1 -30 1 -20 1 6 1 24 1 5 1 31 1 14 1 -34 1 -22 1 -45 1 37 1 46 1 9 1 22 1 -9 1 9 1 -46 1 -47 1 39 1 36 1 -36 1 50
output:
491 481 474 476 484 486 496 501 489 482 467 479 495 498 505 502 505 490 474 487 499 487 504
result:
ok 23 numbers
Test #2:
score: -5
Wrong Answer
time: 1ms
memory: 5664kb
input:
12 1 13 79 59 21 32 13 85 40 74 15 49 56 3 31
output:
267
result:
wrong answer 1st numbers differ - expected: '189', found: '267'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #28:
score: 0
Wrong Answer
time: 1ms
memory: 5788kb
input:
1999 2000 1 1 1 1 0 2 0 2 1 0 2 1 2 2 2 1 2 0 0 1 2 2 0 1 0 1 0 2 0 0 2 1 1 1 1 0 1 2 1 2 1 1 1 1 1 0 2 2 0 2 1 1 2 0 0 2 0 0 2 1 2 0 0 1 1 2 0 2 2 2 1 2 0 2 1 2 0 1 2 2 2 1 1 2 1 1 1 1 0 0 1 1 0 1 2 1 0 0 2 0 2 2 2 0 1 1 2 0 0 1 0 0 2 1 2 1 2 0 1 1 2 2 0 0 1 2 2 1 2 1 2 2 2 0 0 1 1 2 1 1 2 2 2 2 2 ...
output:
660 660 660 660 661 661 661 660 660 660 659 661 661 661 662 663 662 661 662 662 661 660 660 660 660 660 660 660 660 660 662 661 661 660 661 660 659 658 658 658 659 658 659 660 660 660 660 660 659 659 659 659 659 659 659 659 659 660 659 658 657 658 657 657 657 657 658 657 656 657 656 656 656 655 655 ...
result:
wrong answer 4th numbers differ - expected: '661', found: '660'
Subtask #4:
score: 0
Wrong Answer
Test #35:
score: 0
Wrong Answer
time: 0ms
memory: 5756kb
input:
2000 1999 0 1 0 3 0 1 0 0 0 0 0 0 0 2 0 0 0 0 3 1 1 0 2 0 0 3 0 0 0 0 0 4 0 0 1 0 1 0 0 0 0 1 2 1 0 0 0 0 7 0 1 3 1 0 1 1 0 3 2 1 0 1 1 3 3 1 0 2 0 0 0 0 0 0 0 0 1 0 0 0 2 0 0 0 0 0 1 2 3 0 1 0 3 3 0 0 0 0 1 0 1 2 0 0 2 2 0 1 2 1 2 0 0 0 1 1 0 1 2 0 0 0 0 2 0 5 0 0 0 0 0 1 0 0 2 0 1 2 0 1 0 0 0 2 0 ...
output:
670 670 670 670 670 670 670 670 669 671 671 671 671 672 672 672 671 671 670 672 670 672 671 671 670 670 669 669 668 668 669 669 668 669 669 669 668 667 668 668 667 667 666 666 665 665 665 665 665 665 665 665 665 665 664 665 665 665 665 665 665 666 665 667 667 667 667 668 668 668 668 668 668 667 667 ...
result:
wrong answer 1st numbers differ - expected: '666', found: '670'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%