QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637414#7037. DistanceAshbourneAC ✓100ms5368kbC++20588b2024-10-13 12:41:482024-10-13 12:41:49

Judging History

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

  • [2024-10-13 12:41:49]
  • 评测
  • 测评结果:AC
  • 用时:100ms
  • 内存:5368kb
  • [2024-10-13 12:41:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read()
{
	ll x;scanf("%lld",&x);return x;
}
int n;
ll a[100010],sum[100010],ans,t;
void work()
{
	n=read();
	for(int i=1;i<n;i++){
		a[i]=read();
		sum[i]=sum[i-1]+a[i];
	}
	ans=0,t=0;
	for(int i=1;i<=n;i++)
	{
		if(i%2==0)
		{
			// cout<<i<<' '<<n+1-i/2<<' '<<i/2-1<<endl;
			t=t+abs(sum[n-i/2]-sum[i/2-1]);
		}
		ans+=t;
		cout<<ans;
		if(i!=n)
			cout<<' ';
	}
}

int main(){
	// freopen("1.in","r",stdin);
	for(int t=read();t;t--)
	{
		work();
		if(t!=1)
			cout<<'\n';
	}
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3788kb

input:

1
5
2 3 1 4

output:

0 10 20 34 48

result:

ok single line: '0 10 20 34 48'

Test #2:

score: 0
Accepted
time: 100ms
memory: 5368kb

input:

1000
9
2923 3524 6268 567 2776 5657 3707 919
4
833 4391 7520
5
1195 8820 9988 1997
8
720 2558 3179 2776 4346 6770 10000
4
9384 5417 1899
10
9426 918 7162 3418 711 830 51 5913 765
8
10000 5011 5601 6629 5743 822 2610
10
7390 6502 5200 6750 3128 5391 3276 1281 1973
8
9218 9883 7924 2515 3582 3101 1173...

output:

0 26341 52682 101522 150362 214470 278578 346029 413480
0 12744 25488 42623
0 22000 44000 84808 125616
0 30349 60698 110676 160654 220933 281212 344267
0 16700 33400 55517
0 29194 58388 106585 154782 215151 275520 340848 406176 472215
0 36416 72832 133054 193276 271471 349666 434490
0 40891 81782 15...

result:

ok 1000 lines

Test #3:

score: 0
Accepted
time: 92ms
memory: 5368kb

input:

10
100000
7717 2923 3524 6268 567 2776 5657 3707 919 3974 9891 833 4391 7520 7340 4804 1195 8820 9988 1997 2607 7542 4336 6343 4526 4027 1397 1188 4715 7295 5569 5608 8172 6143 2243 9852 4793 1264 8062 7068 9426 918 7162 3418 711 830 51 5913 765 9732 4488 4018 5920 8733 4909 9730 3995 8847 5578 890 ...

output:

0 500285140 1000570280 2001123062 3001675844 4502487631 6003299418 8004364723 10005430028 12506738085 15008046142 18009595669 21011145196 24512924548 28014703900 32016701210 36018698520 40520908067 45023117614 50025536100 55027954586 60530568074 66033181562 72035975975 78038770388 84541735484 910447...

result:

ok 10 lines