QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#115387#6630. Triangle Collectioncsy2005#0 64ms3764kbC++142.0kb2023-06-26 08:34:052024-05-31 14:12:46

Judging History

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

  • [2024-05-31 14:12:46]
  • 评测
  • 测评结果:0
  • 用时:64ms
  • 内存:3764kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-26 08:34:05]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#include<cassert>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(((long long)(n))-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
#define pb push_back
#define mk make_pair
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
typedef long long i64;
typedef long double f80;
typedef unsigned int u32;
typedef unsigned long long u64;
//typedef __int128 i128;
//typedef unsigned __int128 u128;
#ifndef ONLINE_JUDGE
	FILE *___=freopen("1.in","r",stdin);
#endif
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
int n,q,i,j,a[200005];
i64 solve()
{
	i64 ans=0;int i;priority_queue<int> pq;
	fd1(i,n){
		while(!pq.empty()&&pq.top()>=i+i)pq.pop();
		int rem=a[i];
		while(!pq.empty()&&rem>=2){
			rem-=2;ans++;pq.pop();
		}
		ans+=(rem/3);rem%=3;
		while(rem) pq.push(i),rem--;
	}
	return ans;
}
int main()
{
	read(n);read(q);fz1(i,n)read(a[i]);
	while(q--){
		int x,c;read(x);read(c);a[x]+=c;
		printf("%lld\n",solve());
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 0ms
memory: 3760kb

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: 0ms
memory: 3688kb

input:

12 1
13 79 59 21 32 13 85 40 74 15 49 56
3 31

output:

188

result:

wrong answer 1st numbers differ - expected: '189', found: '188'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #28:

score: 0
Wrong Answer
time: 35ms
memory: 3728kb

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:

658
658
658
658
658
658
658
658
658
658
658
659
660
659
660
660
659
658
659
659
658
657
658
657
657
657
657
657
657
657
657
656
656
656
657
656
655
654
654
654
655
654
654
655
655
655
655
655
654
654
654
654
654
654
654
654
654
655
654
653
653
653
653
652
652
651
652
651
651
651
651
651
650
650
650
...

result:

wrong answer 1st numbers differ - expected: '660', found: '658'

Subtask #4:

score: 0
Wrong Answer

Test #35:

score: 0
Wrong Answer
time: 64ms
memory: 3764kb

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:

660
660
659
659
659
659
659
659
659
660
660
660
660
660
660
660
660
660
660
661
661
661
660
660
659
659
658
658
658
658
659
659
659
659
659
659
658
658
658
658
657
658
657
657
657
657
657
656
656
656
657
656
656
656
656
656
656
656
656
656
656
657
656
657
657
658
657
657
658
658
658
658
658
657
657
...

result:

wrong answer 1st numbers differ - expected: '666', found: '660'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%