UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#200916#3476. meanAllen123456hello1003087ms8712kbC++11407b2024-01-14 10:57:482024-01-14 12:21:07

answer

#include <bits/stdc++.h>
#define flt long double
using namespace std;
long long s[1000005];
int n,T,l,r;
signed main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++){
        scanf("%lld",s+i);
        s[i]+=s[i-1];
    }
    scanf("%d",&T);
    ++T;while (--T){
        scanf("%d%d",&l,&r);
        printf("%lld\n",(long long)((flt)(s[r]-s[l-1])/(flt)(r-l+1)+0.5L));
    }
    return 0;
}

Details

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

Test #1:

score: 10
Accepted
time: 74ms
memory: 7456kb

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: 80ms
memory: 7884kb

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: 101ms
memory: 8712kb

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: 350ms
memory: 1192kb

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: 200ms
memory: 1192kb

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: 354ms
memory: 7440kb

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: 616ms
memory: 8300kb

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: 433ms
memory: 8708kb

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: 685ms
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