UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#200949#3476. meanJosephcheng1002503ms8716kbC++11456b2024-01-14 11:42:522024-01-14 12:26:52

answer

#include<bits/stdc++.h>
#define MAXN 1000005
#define LL long long
using namespace std;

LL n,q,a,l,r;
LL sum[MAXN];

int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a),sum[i]=sum[i-1]+a;
	scanf("%lld",&q);
	for(int i=1;i<=q;i++){
		scanf("%lld%lld",&l,&r);
		double ans=(sum[r]-sum[l-1])*1.0/(r-l+1)*1.0;
		LL ans1;
		if(ans-((LL)ans)*1.0>=0.5) ans1=(LL)ans+1;
		else ans1=(LL)ans;
		printf("%lld\n",ans1);
	}
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 85ms
memory: 7464kb

input:

802359
912719068 704515790 229260199 147592601 312951151 239675158 671289693 396533497 214225100 351...

output:

500564476
499469854
499621589
499456356
500030299
499936256
499191151
500273086
499556786
499729309
...

result:

ok 95 lines

Test #2:

score: 10
Accepted
time: 92ms
memory: 7888kb

input:

856789
436628446 522435140 886290426 371544486 140658028 264319851 246610314 849637492 481286113 457...

output:

498797399
499371543
499605175
499167743
499547676
498915341
499516905
499193992
499829931
499653481
...

result:

ok 89 lines

Test #3:

score: 10
Accepted
time: 96ms
memory: 8716kb

input:

963191
124823163 73711809 282792245 299624165 110213053 42689429 315009647 620344825 711634010 11772...

output:

500453327
500177494
500389225
499623736
498718041
499340052
505077424
500546239
499129066
499867309
...

result:

ok 94 lines

Test #4:

score: 10
Accepted
time: 194ms
memory: 1196kb

input:

976
414673811 380827949 420621127 325166534 694701737 14866736 322801732 174342675 467328763 1839471...

output:

508678795
500685551
474032862
480904247
492307446
516544445
466249421
490229404
523292575
507345263
...

result:

ok 863378 lines

Test #5:

score: 10
Accepted
time: 228ms
memory: 1200kb

input:

968
558399544 872858753 867775703 642101609 744642687 204662881 643698805 961699239 35971085 9926599...

output:

500358699
498820910
479586977
484673473
488465892
495508264
475098765
458782100
474987709
489947440
...

result:

ok 988402 lines

Test #6:

score: 10
Accepted
time: 214ms
memory: 1200kb

input:

853
379484167 282820618 974900180 531885211 180659147 389357480 376440629 621015893 53188913 7620274...

output:

527714076
511412344
526819205
492283093
519952403
505463613
479676128
510113599
524994315
506857449
...

result:

ok 892078 lines

Test #7:

score: 10
Accepted
time: 391ms
memory: 7444kb

input:

800448
915749806 986005732 843877066 839276179 942646467 440887278 238109891 237788490 336663914 741...

output:

500007117
502134664
500000808
499877067
499804988
500036440
500219877
500140555
500835287
499954446
...

result:

ok 862332 lines

Test #8:

score: 10
Accepted
time: 431ms
memory: 8304kb

input:

910020
409646942 798941054 986237048 952317339 744506356 253468691 250713874 951258324 251238795 162...

output:

499998355
498816258
498916881
499984440
500473751
497777599
500091170
499683782
499300019
499726509
...

result:

ok 928683 lines

Test #9:

score: 10
Accepted
time: 378ms
memory: 8712kb

input:

962278
437503795 746318731 650992126 517597648 62547645 363757627 50133504 879724484 256107080 90299...

output:

500320294
500368301
500072158
500294637
500320037
500449056
500303429
500245330
500452499
500363759
...

result:

ok 830036 lines

Test #10:

score: 10
Accepted
time: 394ms
memory: 7764kb

input:

841196
35003476 996569888 819223426 120265507 381282861 782983436 527480694 378886824 552555251 2067...

output:

500181511
499656736
499453473
500783583
500125194
500122342
500679402
499826895
499711059
500528750
...

result:

ok 831267 lines